django-webpack-configuration

Django webpack configuration (django-configurations)


Keywords
django, webpack, configuration, python
License
Unlicense
Install
pip install django-webpack-configuration==2020.5.25

Documentation

Travis

Installation

$ [sudo] pip install django-webpack-configuration

Examples

settings.py

from django_webpack_configuration import WebpackDevConfiguration, WebpackProdConfiguration

class Dev(WebpackDevConfiguration,...):
    ...

class Prod(WebpackProdConfiguration,...):
    ...

webpack.config.js

var path = require('path');
var BundleTracker = require('webpack-bundle-tracker');

module.exports = {
  output: {
      path: path.resolve('./assets/webpack_bundles/')
  },

  plugins: [
    new BundleTracker({filename: './webpack-stats.json'}) // './webpack-stats-prod.json' (prod)
  ]
}

template

{% load render_bundle from webpack_loader %}
<head>
{% render_bundle 'main' 'css' %}
</head>
<body>
...
{% render_bundle 'main' 'js' %}
</body>

customize

class Prod(WebpackProdConfiguration,...):
    WEBPACK_STATS_FILE = './webpack-stats-custom.json'

.env

DJANGO_WEBPACK_STATS_FILE='./webpack-stats-custom.json'

Links

python-readme-generator