https://github.com/marinko-peso/django-apps-webpack-alias
:snake: Automatically discovery django apps folder and create webpack alias for them with the app name
https://github.com/marinko-peso/django-apps-webpack-alias
Last synced: 25 days ago
JSON representation
:snake: Automatically discovery django apps folder and create webpack alias for them with the app name
- Host: GitHub
- URL: https://github.com/marinko-peso/django-apps-webpack-alias
- Owner: marinko-peso
- License: mit
- Created: 2018-06-10T19:18:32.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-27T23:46:04.000Z (about 2 years ago)
- Last Synced: 2025-02-13T16:19:24.347Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 240 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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)
[](https://codecov.io/gh/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.
If you are using Jest (and you should) also check out [django-apps-jest-mapper](https://npm.im/django-apps-jest-mapper) to follow same naming in both configurations.## 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 (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.