django-configurations-webpack

django-configurations webpack settings


Keywords
django, webpack, configuration
License
Unlicense
Install
pip install django-configurations-webpack==2020.10.25

Documentation

Installation

$ [sudo] pip install django-configurations-webpack

Examples

settings.py

from configurations import Configuration
from django_configurations_webpack import WebpackDevMixin, WebpackProdMixin

class Dev(WebpackDevMixin,Configuration):
    ... # WEBPACK_STATS_FILE ./webpack-stats.json by default

class Prod(WebpackProdMixin,Configuration):
    ... # WEBPACK_STATS_FILE ./webpack-stats-prod.json by default

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>

Links

readme42.com