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
INSTALLED_APPS = [
...
'djangomix',
]
Include in base.html (or any other template)
{% load mix %}
Use mix template tag in your templates to load scripts, styles,...
Note: Second parameter is path to manifest.json
<script src="{% mix 'build/app.js' 'polls/static' %}"></script>
The paths are related to webpack.mix.js configuration.
You can set path for manifest dir and public path also in Django settings
MANIFEST_DIRECTORY = getattr(settings, 'LARAVELMIX_MANIFEST_DIRECTORY','')
PUBLIC_URL = getattr(settings, 'LARAVELMIX_PUBLIC_URL', settings.STATIC_URL)
Example configration of webpack.mix.js:
let mix = require('laravel-mix');
let staticPath = 'polls/static/build'
let resourcesPath = 'polls/resources'
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
// if you don't need browser-sync feature you can remove this lines
if (process.argv.includes('--browser-sync')) {
mix.browserSync('localhost:8000')
}
// Now you can use full mix api
mix.js(`${resourcesPath}/js/app.js`, `${staticPath}/`)
mix.sass(`${resourcesPath}/sass/app.scss`, `${staticPath}/`)
Do you have problem with setup? Read how to setup and start with Vue in Django
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
Built Distribution
File details
Details for the file djangomix-1.1.3.tar.gz
.
File metadata
- Download URL: djangomix-1.1.3.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d95abdb77c0dead54b57277615cdbfe830614882b0b037151dbf66dbbe04a7f0 |
|
MD5 | 671518fcd8b3f1cdd354a38a7563da78 |
|
BLAKE2b-256 | f33926ebb02860e9266bad7e3fb8a6b67b316a01e8a3cb09e462a5bd17d00dcb |
File details
Details for the file djangomix-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: djangomix-1.1.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c81cead04a97e7606d862fc762839ba46845f25674280c3024b805e31484d4f1 |
|
MD5 | cf546c1773a7a3d1a40068b8f2fe232f |
|
BLAKE2b-256 | 2e4cff1f98e2e308498024aa9c518556c60adecca24b3d7729d2674e61311c06 |