django-apps-webpack-alias
v1.0.6
Published
Automatically discovery django apps folder and create webpack alias for them with the app name
Downloads
83
Maintainers
Readme
Django Apps Webpack Alias
Automatically discovery django apps folder and create webpack alias for them with the app name.
Why?
If you need to start using Webpack on a Django organized project it can be a pain. Static files are usually organized per django app, and communication between them using relative paths can soon become messy. This way you can generate Webpack alias for all Django apps automatically and let Webpack handle the messy part for you. If you are using Jest (and you should) also check out django-apps-jest-mapper to follow same naming in both configurations.
Install
npm i -D django-apps-webpack-alias
Running
const djangoAppsAlias = require('django-apps-webpack-alias');
// in webpack alias config just spread it (or Object.assign with other alias entries)
alias: {
...djangoAppsAlias({ options })
},
Available options:
- dir [default 'apps'] path to directory holding the apps (example: path.resolve(__dirname, 'project/apps'))
- prefix [default '@app:'] each app alias prefix, for instance for auth app it will generate
@app:auth
All aliases point to app/static/app/js directory.
License
MIT.