Django integration for Laravel Mix
Project description
Django Mix
Django integration for Laravel Mix
Laravel Mix helper in python representation to easy usage with laravel-mix npm package in Django projects.
Installation
Django:
pip install djangomix
Note: Do not forget to include the package in requirements
Laravel Mix NPM package:
Follow instructions on Laravel Mix webpage
Please, see example of webpack.mix.js configration below.
Usage
Add 'djangomix' to INSTALLED APPS in Django config
Include in base.html (or any other template)
{% load mix %}
Use mix template tag in your templates to load scripts, styles,...
<script src="{% mix 'app.js' 'polls/static' %}"></script>
The paths are related to webpack.mix.js configuration.
Example configration of webpack.mix.js:
let mix = require('laravel-mix');
let staticPath = 'polls/static'
let resourcesPath = 'polls/resources'
// if you don't need browser-sync feature you can remove this lines
if (process.argv.includes('--browser-sync')) {
mix.browserSync('localhost:8000')
}
mix.setResourceRoot('/static/build') // setResroucesRoots add prefix to url() in scss on example: from /images/close.svg to /static/images/close.svg
mix.setPublicPath('polls/static') // Path where mix-manifest.json is created
mix.js(`${resourcesPath}/js/app.js`, `${staticPath}/`)
Maintained by: Marek Racík from IdeaLoop
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
djangomix-1.1.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for djangomix-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d0cddd99a537f63bb314e61620561011ea1e546029bb63bae6b09a803428f77 |
|
MD5 | 9d0dff6972556e3811693b5fdeaa7e35 |
|
BLAKE2b-256 | df46e5f6c2b643568e92edeee66aa340683359e80bdc52f280a978e64b77652e |