django-apps-webpack-alias

1.0.6 • Public • Published

Django Apps Webpack Alias

Open Source Love license js-semistandard-style package version install size dependecies codecov

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.

Package Sidebar

Install

npm i django-apps-webpack-alias

Weekly Downloads

17

Version

1.0.6

License

MIT

Unpacked Size

5.33 kB

Total Files

4

Last publish

Collaborators

  • marinko-peso