django-apps-webpack-alias
Version:
Automatically discovery django apps folder and create webpack alias for them with the app name
46 lines (29 loc) • 1.86 kB
Markdown
# Django Apps Webpack Alias
[](https://github.com/ellerbrock/open-source-badges/)
[](https://github.com/marinko-peso/django-apps-webpack-alias/blob/master/LICENSE)
[](https://github.com/Flet/semistandard)
[](https://npm.im/django-apps-webpack-alias)
[](https://packagephobia.now.sh/result?p=django-apps-webpack-alias)
[](https://david-dm.org/marinko-peso/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.
## Install
```ssh
npm -i -D django-apps-webpack-alias
```
## Running
```js
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
- 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