Django integration with Webpack Encore
Project description
Django Encore
This library integrates Webpack Encore into your Django application like it does Webpack Encore Bundle for Symfony.
Usage
- Install the library from PyPI:
pip install django-encore
- Configure your settings.py file:
Include the library:
INSTALLED_APPS = [
# ...
'encore',
]
Add ENCORE_ENTRYPOINTS_FILE and change STATICFILES_DIRS:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'assets_build'),
]
ENCORE_ENTRYPOINTS_FILE = os.path.join(BASE_DIR, 'assets_build') + '/build/entrypoints.json'
- Use template tags in your templates:
{% load encore %}
{% block javascripts %}
{{ block.super }}
{% encore_entry_script_tags 'demo1' %}
{% endblock %}
{% block stylesheets %}
{{ block.super }}
{% encore_entry_link_tags 'demo1' %}
{% endblock %}
See the example folder for more details.
Development
First of all, install dependencies by pipenv:
cd example/webapp
pipenv install --dev
pipenv shell # to shell with virtual environment
Second, build files using Encore:
npm run dev
Then you can start the web server:
python manage.py runserver
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
django-encore-0.0.2.tar.gz
(2.8 kB
view hashes)
Built Distributions
django_encore-0.0.2-py3.6.egg
(3.1 kB
view hashes)
Close
Hashes for django_encore-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3508c601dbc867c0b42a45e6161d3f4ea62a0e0481041fe4a2879fa5c932ab95 |
|
MD5 | 7c59b300fcd8286e3e7e86aa30480d52 |
|
BLAKE2b-256 | 2673b88a7a9905f480cad43f01d785dab558da6f9f3c27bce2bb5de11750afe2 |