Skip to main content

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

  1. Install the library from PyPI:
pip install django-encore
  1. 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'
  1. 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


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)

Uploaded Source

Built Distributions

django_encore-0.0.2-py3.6.egg (3.1 kB view hashes)

Uploaded Source

django_encore-0.0.2-py2.py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page