1 | # Django Apps Webpack Alias
|
2 | [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)
|
3 | [![license](https://img.shields.io/github/license/marinko-peso/django-apps-webpack-alias.svg)](https://github.com/marinko-peso/django-apps-webpack-alias/blob/master/LICENSE)
|
4 | [![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg)](https://github.com/Flet/semistandard)
|
5 | [![package version](https://img.shields.io/npm/v/django-apps-webpack-alias.svg)](https://npm.im/django-apps-webpack-alias)
|
6 | [![install size](https://packagephobia.now.sh/badge?p=django-apps-webpack-alias)](https://packagephobia.now.sh/result?p=django-apps-webpack-alias)
|
7 | [![dependecies](https://david-dm.org/marinko-peso/django-apps-webpack-alias.svg)](https://david-dm.org/marinko-peso/django-apps-webpack-alias)
|
8 | [![codecov](https://codecov.io/gh/marinko-peso/django-apps-webpack-alias/branch/master/graph/badge.svg)](https://codecov.io/gh/marinko-peso/django-apps-webpack-alias)
|
9 |
|
10 | Automatically discovery django apps folder and create webpack alias for them with the app name.
|
11 |
|
12 |
|
13 | ## Why?
|
14 |
|
15 | 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.
|
16 | This way you can generate Webpack alias for all Django apps automatically and let Webpack handle the messy part for you.
|
17 | 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.
|
18 |
|
19 |
|
20 | ## Install
|
21 |
|
22 | ```ssh
|
23 | npm i -D django-apps-webpack-alias
|
24 | ```
|
25 |
|
26 |
|
27 | ## Running
|
28 |
|
29 | ```js
|
30 | const djangoAppsAlias = require('django-apps-webpack-alias');
|
31 |
|
32 | // in webpack alias config just spread it (or Object.assign with other alias entries)
|
33 | alias: {
|
34 | ...djangoAppsAlias({ options })
|
35 | },
|
36 | ```
|
37 |
|
38 | Available options:
|
39 | - dir [default 'apps'] path to directory holding the apps (example: path.resolve(__dirname, 'project/apps'))
|
40 | - prefix [default '@app:'] each app alias prefix, for instance for auth app it will generate ``` @app:auth ```
|
41 |
|
42 | All aliases point to app/static/app/js directory.
|
43 |
|
44 |
|
45 | ## License
|
46 |
|
47 | MIT.
|
48 |
|
\ | No newline at end of file |