[Python-modules-commits] [django-webpack-loader] 01/04: Import django-webpack-loader_0.4.1.orig.tar.gz
Michael Fladischer
fladi at moszumanska.debian.org
Tue Nov 8 21:31:40 UTC 2016
This is an automated email from the git hooks/post-receive script.
fladi pushed a commit to branch master
in repository django-webpack-loader.
commit f54b546133a1b6e307672c20a076e0afb68b13c0
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date: Tue Nov 8 22:05:19 2016 +0100
Import django-webpack-loader_0.4.1.orig.tar.gz
---
PKG-INFO | 565 +++++++++++++++-----------
README.md | 35 +-
README.rst | 427 +++++++++++++++++++
django_webpack_loader.egg-info/PKG-INFO | 565 +++++++++++++++-----------
django_webpack_loader.egg-info/SOURCES.txt | 1 +
setup.cfg | 2 +-
setup.py | 3 +-
webpack_loader/__init__.py | 2 +-
webpack_loader/exceptions.py | 11 +-
webpack_loader/loader.py | 9 +-
webpack_loader/templatetags/webpack_loader.py | 4 +-
11 files changed, 1111 insertions(+), 513 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 80a0c18..52ac730 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,367 +1,440 @@
Metadata-Version: 1.1
Name: django-webpack-loader
-Version: 0.3.3
+Version: 0.4.1
Summary: Transparently use webpack with django
Home-page: https://github.com/owais/django-webpack-loader
Author: Owais Lone
Author-email: hello at owaislone.org
License: UNKNOWN
-Download-URL: https://github.com/owais/django-webpack-loader/tarball/0.3.3
-Description: # django-webpack-loader
+Download-URL: https://github.com/owais/django-webpack-loader/tarball/0.4.1
+Description: django-webpack-loader
+ =====================
- [![Join the chat at https://gitter.im/owais/django-webpack-loader](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/owais/django-webpack-loader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
- [![Build Status](https://travis-ci.org/owais/django-webpack-loader.svg?branch=master)](https://travis-ci.org/owais/django-webpack-loader)
- [![Coverage Status](https://coveralls.io/repos/owais/django-webpack-loader/badge.svg?branch=master&service=github)](https://coveralls.io/github/owais/django-webpack-loader?branch=master)
+ |Join the chat at https://gitter.im/owais/django-webpack-loader| |Build
+ Status| |Coverage Status|
- <br>
- Read http://owaislone.org/blog/webpack-plus-reactjs-and-django/ for a detailed step by step guide on setting up webpack with django using this library.
+ Read http://owaislone.org/blog/webpack-plus-reactjs-and-django/ for a
+ detailed step by step guide on setting up webpack with django using this
+ library.
- <br>
+ Use webpack to generate your static bundles without django's staticfiles
+ or opaque wrappers.
- Use webpack to generate your static bundles without django's staticfiles or opaque wrappers.
+ Django webpack loader consumes the output generated by
+ `webpack-bundle-tracker <https://github.com/owais/webpack-bundle-tracker>`__
+ and lets you use the generated bundles in django.
+ Maintainers
+ -----------
- Django webpack loader consumes the output generated by [webpack-bundle-tracker](https://github.com/owais/webpack-bundle-tracker) and lets you use the generated bundles in django.
+ In order to overcome the lack of support for Markdown on PyPi, building
+ this package can use `pandoc <http://pandoc.org/installing.html>`__
+ along with `pypandoc <https://pypi.python.org/pypi/pypandoc>`__ to
+ convert the README.md into a Restructured Text format compatible with
+ PyPI. This requires installing ``pandoc`` for your operating system
+ (installation instructions on the pandoc site), and ``pypandoc`` which
+ will be installed if you:
+ ::
- <br>
- ## Compatibility
+ pip install -r requirements-dev.txt
- Test cases cover Django>=1.6 on Python 2.7 and Python>=3.3. 100% code coverage is the target so we can be sure everything works anytime. It should probably work on older version of django as well but the package does not ship any test cases for them.
+ before uploading to PyPI.
+ If pandoc or pypandoc fails, the README.md file will be uploaded as it
+ was before this enhancement.
- ## Install
+ Compatibility
+ -------------
- ```bash
- npm install --save-dev webpack-bundle-tracker
+ Test cases cover Django>=1.6 on Python 2.7 and Python>=3.3. 100% code
+ coverage is the target so we can be sure everything works anytime. It
+ should probably work on older version of django as well but the package
+ does not ship any test cases for them.
- pip install django-webpack-loader
- ```
+ Install
+ -------
- <br>
- ## Configuration
+ .. code:: bash
- <br>
- ### Assumptions
+ npm install --save-dev webpack-bundle-tracker
- Assuming `BASE_DIR` in settings refers to the root of your django app.
- ```python
- import sys
- import os
+ pip install django-webpack-loader
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- ```
+ ## Configuration
- <br>
- Assuming `assets/` is in `settings.STATICFILES_DIRS` like
+ ### Assumptions
- ```python
- STATICFILES_DIRS = (
- os.path.join(BASE_DIR, 'assets'),
- )
- ```
+ Assuming ``BASE_DIR`` in settings refers to the root of your django app.
- <br>
- Assuming your webpack config lives at `./webpack.config.js` and looks like this
- ```javascript
- var path = require("path");
- var webpack = require('webpack');
- var BundleTracker = require('webpack-bundle-tracker');
+ .. code:: python
- module.exports = {
- context: __dirname,
- entry: './assets/js/index',
- output: {
- path: path.resolve('./assets/bundles/'),
- filename: "[name]-[hash].js"
- },
+ import sys
+ import os
- plugins: [
- new BundleTracker({filename: './webpack-stats.json'})
- ]
- }
- ```
-
-
- <br>
- ### Default Configuration
- ```python
- WEBPACK_LOADER = {
- 'DEFAULT': {
- 'CACHE': not DEBUG,
- 'BUNDLE_DIR_NAME': 'bundles/', # must end with slash
- 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
- 'POLL_INTERVAL': 0.1,
- 'TIMEOUT': None,
- 'IGNORE': ['.+\.hot-update.js', '.+\.map']
- }
- }
- ```
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+ Assuming ``assets/`` is in ``settings.STATICFILES_DIRS`` like
+
+ .. code:: python
+
+ STATICFILES_DIRS = (
+ os.path.join(BASE_DIR, 'assets'),
+ )
+
+ Assuming your webpack config lives at ``./webpack.config.js`` and looks
+ like this
+
+ .. code:: javascript
+
+ var path = require("path");
+ var webpack = require('webpack');
+ var BundleTracker = require('webpack-bundle-tracker');
- <br>
+ module.exports = {
+ context: __dirname,
+ entry: './assets/js/index',
+ output: {
+ path: path.resolve('./assets/webpack_bundles/'),
+ filename: "[name]-[hash].js"
+ },
- #### CACHE
- ```python
- WEBPACK_LOADER = {
- 'DEFAULT': {
- 'CACHE': not DEBUG
+ plugins: [
+ new BundleTracker({filename: './webpack-stats.json'})
+ ]
}
- }
- ```
- When `CACHE` is set to True, webpack-loader will read the stats file only once and cache the result. This means web workers need to be restarted in order to pick up any changes made to the stats files.
- <br>
+ Default Configuration
+ ~~~~~~~~~~~~~~~~~~~~~
- #### BUNDLE_DIR_NAME
- ```python
- WEBPACK_LOADER = {
- 'DEFAULT': {
- 'BUNDLE_DIR_NAME': 'bundles/' # end with slash
+ .. code:: python
+
+ WEBPACK_LOADER = {
+ 'DEFAULT': {
+ 'CACHE': not DEBUG,
+ 'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash
+ 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
+ 'POLL_INTERVAL': 0.1,
+ 'TIMEOUT': None,
+ 'IGNORE': ['.+\.hot-update.js', '.+\.map']
+ }
}
- }
- ```
- `BUNDLE_DIR_NAME` refers to the dir in which webpack outputs the bundles. It should not be the full path. If `./assets` is one of you static dirs and webpack generates the bundles in `./assets/output/bundles/`, then `BUNDLE_DIR_NAME` should be `output/bundles/`.
+ CACHE
+ ^^^^^
+
+ .. code:: python
+
+ WEBPACK_LOADER = {
+ 'DEFAULT': {
+ 'CACHE': not DEBUG
+ }
+ }
- If the bundle generates a file called `main-cf4b5fab6e00a404e0c7.js` and your STATIC_URL is `/static/`, then the `<script>` tag will look like this
+ When ``CACHE`` is set to True, webpack-loader will read the stats file
+ only once and cache the result. This means web workers need to be
+ restarted in order to pick up any changes made to the stats files.
- ```html
- <script type="text/javascript" src="/static/output/bundles/main-cf4b5fab6e00a404e0c7.js"/>
- ```
+ BUNDLE\_DIR\_NAME
+ ^^^^^^^^^^^^^^^^^
- <br>
+ .. code:: python
- #### STATS_FILE
- ```python
- WEBPACK_LOADER = {
- 'DEFAULT': {
- 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json')
+ WEBPACK_LOADER = {
+ 'DEFAULT': {
+ 'BUNDLE_DIR_NAME': 'bundles/' # end with slash
+ }
}
- }
- ```
- `STATS_FILE` is the filesystem path to the file generated by `webpack-bundle-tracker` plugin. If you initialize `webpack-bundle-tracker` plugin like this
+ ``BUNDLE_DIR_NAME`` refers to the dir in which webpack outputs the
+ bundles. It should not be the full path. If ``./assets`` is one of you
+ static dirs and webpack generates the bundles in
+ ``./assets/output/bundles/``, then ``BUNDLE_DIR_NAME`` should be
+ ``output/bundles/``.
+
+ If the bundle generates a file called ``main-cf4b5fab6e00a404e0c7.js``
+ and your STATIC\_URL is ``/static/``, then the ``<script>`` tag will
+ look like this
- ```javascript
- new BundleTracker({filename: './webpack-stats.json'})
- ```
+ .. code:: html
- and your webpack config is located at `/home/src/webpack.config.js`, then the value of `STATS_FILE` should be `/home/src/webpack-stats.json`
+ <script type="text/javascript" src="/static/output/bundles/main-cf4b5fab6e00a404e0c7.js"/>
- <br>
+ STATS\_FILE
+ ^^^^^^^^^^^
- #### IGNORE
- `IGNORE` is a list of regular expressions. If a file generated by webpack matches one of the expressions, the file will not be included in the template.
+ .. code:: python
- <br>
+ WEBPACK_LOADER = {
+ 'DEFAULT': {
+ 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json')
+ }
+ }
- #### POLL_INTERVAL
+ ``STATS_FILE`` is the filesystem path to the file generated by
+ ``webpack-bundle-tracker`` plugin. If you initialize
+ ``webpack-bundle-tracker`` plugin like this
- `POLL_INTERVAL` is the number of seconds webpack_loader should wait between polling the stats file. The stats file is polled every 100 miliseconds by default and any requests to are blocked while webpack compiles the bundles. You can reduce this if your bundles take shorter to compile.
+ .. code:: javascript
- **NOTE:** Stats file is not polled when in production (DEBUG=False).
+ new BundleTracker({filename: './webpack-stats.json'})
+
+ and your webpack config is located at ``/home/src/webpack.config.js``,
+ then the value of ``STATS_FILE`` should be
+ ``/home/src/webpack-stats.json``
+
+ IGNORE
+ ^^^^^^
+
+ ``IGNORE`` is a list of regular expressions. If a file generated by
+ webpack matches one of the expressions, the file will not be included in
+ the template.
+
+ POLL\_INTERVAL
+ ^^^^^^^^^^^^^^
- <br>
+ ``POLL_INTERVAL`` is the number of seconds webpack\_loader should wait
+ between polling the stats file. The stats file is polled every 100
+ miliseconds by default and any requests to are blocked while webpack
+ compiles the bundles. You can reduce this if your bundles take shorter
+ to compile.
- #### TIMEOUT
+ **NOTE:** Stats file is not polled when in production (DEBUG=False).
- `TIMEOUT` is the number of seconds webpack_loader should wait for webpack to finish compiling before raising an exception. `0`, `None` or leaving the value out of settings disables timeouts.
+ TIMEOUT
+ ^^^^^^^
- <br>
+ ``TIMEOUT`` is the number of seconds webpack\_loader should wait for
+ webpack to finish compiling before raising an exception. ``0``, ``None``
+ or leaving the value out of settings disables timeouts.
+ Usage
+ -----
- ## Usage
- <br>
+ Manually run webpack to build assets.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #### Manually run webpack to build assets.
+ One of the core principles of django-webpack-loader is to not manage
+ webpack itself in order to give you the flexibility to run webpack the
+ way you want. If you are new to webpack, check one of the
+ `examples <https://github.com/owais/django-webpack-loader/tree/master/examples>`__,
+ read `my detailed blog
+ post <http://owaislone.org/blog/webpack-plus-reactjs-and-django/>`__ or
+ check `webpack docs <http://webpack.github.io/>`__.
- One of the core principles of django-webpack-loader is to not manage webpack itself in order to give you the flexibility to run webpack the way you want. If you are new to webpack, check one of the [examples](https://github.com/owais/django-webpack-loader/tree/master/examples), read [my detailed blog post](http://owaislone.org/blog/webpack-plus-reactjs-and-django/) or check [webpack docs](http://webpack.github.io/).
+ Settings
+ ~~~~~~~~
+ Add ``webpack_loader`` to ``INSTALLED_APPS``
- #### Settings
+ ::
- Add `webpack_loader` to `INSTALLED_APPS`
+ INSTALLED_APPS = (
+ ...
+ 'webpack_loader',
+ )
- ```
- INSTALLED_APPS = (
- ...
- 'webpack_loader',
- )
- ```
+ Templates
+ ~~~~~~~~~
- #### Templates
+ .. code:: html+django
- ```HTML+Django
- {% load render_bundle from webpack_loader %}
+ {% load render_bundle from webpack_loader %}
- {% render_bundle 'main' %}
- ```
+ {% render_bundle 'main' %}
- `render_bundle` will render the proper `<script>` and `<link>` tags needed in your template.
+ ``render_bundle`` will render the proper ``<script>`` and ``<link>``
+ tags needed in your template.
- `render_bundle` also takes a second argument which can be a file extension to match. This is useful when you want to render different types for files in separately. For example, to render CSS in head and JS at bottom we can do something like this,
+ ``render_bundle`` also takes a second argument which can be a file
+ extension to match. This is useful when you want to render different
+ types for files in separately. For example, to render CSS in head and JS
+ at bottom we can do something like this,
- ```HTML+Django
- {% load render_bundle from webpack_loader %}
+ .. code:: html+django
- <html>
- <head>
- {% render_bundle 'main' 'css' %}
- </head>
- <body>
- ....
- {% render_bundle 'main' 'js' %}
- </body>
- </head>
- ```
+ {% load render_bundle from webpack_loader %}
- <br>
+ <html>
+ <head>
+ {% render_bundle 'main' 'css' %}
+ </head>
+ <body>
+ ....
+ {% render_bundle 'main' 'js' %}
+ </body>
+ </head>
+ Multiple webpack projects
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
- #### Multiple webpack projects
+ Version 2.0 and up of webpack loader also supports multiple webpack
+ configurations. The following configuration defines 2 webpack stats
+ files in settings and uses the ``config`` argument in the template tags
+ to influence which stats file to load the bundles from.
- Version 2.0 and up of webpack loader also supports multiple webpack configurations. The following configuration defines 2 webpack stats files in settings and uses the `config` argument in the template tags to influence which stats file to load the bundles from.
+ .. code:: python
- ```python
- WEBPACK_LOADER = {
- 'DEFAULT': {
- 'BUNDLE_DIR_NAME': 'bundles/',
- 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
- },
- 'DASHBOARD': {
- 'BUNDLE_DIR_NAME': 'dashboard_bundles/',
- 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats-dashboard.json'),
+ WEBPACK_LOADER = {
+ 'DEFAULT': {
+ 'BUNDLE_DIR_NAME': 'bundles/',
+ 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
+ },
+ 'DASHBOARD': {
+ 'BUNDLE_DIR_NAME': 'dashboard_bundles/',
+ 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats-dashboard.json'),
+ }
}
- }
- ```
- ```HTML+Django
- {% load render_bundle from webpack_loader %}
+ .. code:: html+django
- <html>
- <body>
- ....
- {% render_bundle 'main' 'js' 'DEFAULT' %}
- {% render_bundle 'main' 'js' 'DASHBOARD' %}
+ {% load render_bundle from webpack_loader %}
- <!-- or render all files from a bundle -->
- {% render_bundle 'main' config='DASHBOARD' %}
+ <html>
+ <body>
+ ....
+ {% render_bundle 'main' 'js' 'DEFAULT' %}
+ {% render_bundle 'main' 'js' 'DASHBOARD' %}
- <!-- the following tags do the same thing -->
- {% render_bundle 'main' 'css' 'DASHBOARD' %}
- {% render_bundle 'main' extension='css' config='DASHBOARD' %}
- {% render_bundle 'main' config='DASHBOARD' extension='css' %}
+ <!-- or render all files from a bundle -->
+ {% render_bundle 'main' config='DASHBOARD' %}
- <!-- add some extra attributes to the tag -->
- {% render_bundle 'main' 'js' 'DEFAULT' attrs='async chatset="UTF-8"'%}
- </body>
- </head>
- ```
+ <!-- the following tags do the same thing -->
+ {% render_bundle 'main' 'css' 'DASHBOARD' %}
+ {% render_bundle 'main' extension='css' config='DASHBOARD' %}
+ {% render_bundle 'main' config='DASHBOARD' extension='css' %}
- #### File URLs instead of html tags
+ <!-- add some extra attributes to the tag -->
+ {% render_bundle 'main' 'js' 'DEFAULT' attrs='async chatset="UTF-8"'%}
+ </body>
+ </head>
- If you need the URL to an asset without the HTML tags, the `get_files`
+ File URLs instead of html tags
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ If you need the URL to an asset without the HTML tags, the ``get_files``
template tag can be used. A common use case is specifying the URL to a
custom css file for a Javascript plugin.
- `get_files` works exactly like `render_bundle` except it returns a list of
- matching files and lets you assign the list to a custom template variable. For example,
+ ``get_files`` works exactly like ``render_bundle`` except it returns a
+ list of matching files and lets you assign the list to a custom template
+ variable. For example,
+
+ .. code:: html+django
- ```HTML+Django
- {% get_files 'editor' 'css' as editor_css_files %}
- CKEDITOR.config.contentsCss = '{{ editor_css_files.0.publicPath }}';
+ {% get_files 'editor' 'css' as editor_css_files %}
+ CKEDITOR.config.contentsCss = '{{ editor_css_files.0.publicPath }}';
- <!-- or list down name, path and download url for every file -->
- <ul>
- {% for css_file in editor_css_files %}
- <li>{{ css_file.name }} : {{ css_file.path }} : {{ css_file.publicPath }}</li>
- {% endfor %}
- </ul>
- ```
+ <!-- or list down name, path and download url for every file -->
+ <ul>
+ {% for css_file in editor_css_files %}
+ <li>{{ css_file.name }} : {{ css_file.path }} : {{ css_file.publicPath }}</li>
+ {% endfor %}
+ </ul>
- #### Refer other static assets
+ Refer other static assets
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
- `webpack_static` template tag provides facilities to load static assets managed by webpack
- in django templates. It is like django's built in `static` tag but for webpack assets instead.
- In the below example, `logo.png` can be any static asset shipped with any npm or bower package.
+ ``webpack_static`` template tag provides facilities to load static
+ assets managed by webpack in django templates. It is like django's built
+ in ``static`` tag but for webpack assets instead. In the below example,
+ ``logo.png`` can be any static asset shipped with any npm or bower
+ package.
- ```HTML+Django
- {% load webpack_static from webpack_loader %}
+ .. code:: html+django
- <!-- render full public path of logo.png -->
- <img src="{% webpack_static 'logo.png' %}"/>
- ```
+ {% load webpack_static from webpack_loader %}
- <br>
+ <!-- render full public path of logo.png -->
+ <img src="{% webpack_static 'logo.png' %}"/>
- ## How to use in Production
+ How to use in Production
+ ------------------------
- **It is up to you**. There are a few ways to handle this. I like to have slightly separate configs for production and local. I tell git to ignore my local stats + bundle file but track the ones for production. Before pushing out newer version to production, I generate a new bundle using production config and commit the new stats file and bundle. I store the stats file and bundles in a directory that is added to the `STATICFILES_DIR`. This gives me integration with collectstatic f [...]
+ **It is up to you**. There are a few ways to handle this. I like to have
+ slightly separate configs for production and local. I tell git to ignore
+ my local stats + bundle file but track the ones for production. Before
+ pushing out newer version to production, I generate a new bundle using
+ production config and commit the new stats file and bundle. I store the
+ stats file and bundles in a directory that is added to the
+ ``STATICFILES_DIR``. This gives me integration with collectstatic for
+ free. The generated bundles are automatically collected to the target
+ directory and synched to S3.
+ ``./webpack_production.config.js``
- `./webpack_production.config.js`
- ```javascript
- config = require('./webpack.config.js');
+ .. code:: javascript
- config.output.path = require('path').resolve('./assets/dist');
+ var config = require('./webpack.config.js');
+ var BundleTracker = require('webpack-bundle-tracker');
- config.plugins = [
- new BundleTracker({filename: './webpack-stats-prod.json'})
- ]
+ config.output.path = require('path').resolve('./assets/dist');
- // override any other settings here like using Uglify or other things that make sense for production environments.
+ config.plugins = [
+ new BundleTracker({filename: './webpack-stats-prod.json'})
+ ]
- module.exports = config;
- ```
+ // override any other settings here like using Uglify or other things that make sense for production environments.
- `settings.py`
- ```python
- if not DEBUG:
- WEBPACK_LOADER.update({
- 'BUNDLE_DIR_NAME': 'dist/',
- 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats-prod.json')
- })
- ```
+ module.exports = config;
- <br><br>
+ ``settings.py``
+ .. code:: python
- You can also simply generate the bundles on the server before running collectstatic if that works for you.
+ if not DEBUG:
+ WEBPACK_LOADER.update({
+ 'BUNDLE_DIR_NAME': 'dist/',
+ 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats-prod.json')
+ })
- ## Extra
+ You can also simply generate the bundles on the server before running
+ collectstatic if that works for you.
- ### Jinja2 Configuration
+ Extra
+ -----
- If you need to output your assets in a jinja template we provide a Jinja2 extension that's compatible with the [Django Jinja](https://github.com/niwinz/django-jinja) module and Django 1.8.
+ Jinja2 Configuration
+ ~~~~~~~~~~~~~~~~~~~~
- To install the extension add it to the django_jinja `TEMPLATES` configuration in the `["OPTIONS"]["extension"]` list.
+ If you need to output your assets in a jinja template we provide a
+ Jinja2 extension that's compatible with the `Django
+ Jinja <https://github.com/niwinz/django-jinja>`__ module and Django 1.8.
- ```python
- TEMPLATES = [
- {
- "BACKEND": "django_jinja.backend.Jinja2",
- "OPTIONS": {
- "extensions": [
- "django_jinja.builtins.extensions.DjangoFiltersExtension",
- "webpack_loader.contrib.jinja2ext.WebpackExtension",
- ],
+ To install the extension add it to the django\_jinja ``TEMPLATES``
+ configuration in the ``["OPTIONS"]["extension"]`` list.
+
+ .. code:: python
+
+ TEMPLATES = [
+ {
+ "BACKEND": "django_jinja.backend.Jinja2",
+ "OPTIONS": {
+ "extensions": [
+ "django_jinja.builtins.extensions.DjangoFiltersExtension",
+ "webpack_loader.contrib.jinja2ext.WebpackExtension",
+ ],
+ }
}
- }
- ]
- ```
+ ]
Then in your base jinja template:
- ```HTML+Jinja2
- {{ render_bundle('main') }}
- ```
+ .. code:: html
- --------------------
- <br>
+ {{ render_bundle('main') }}
+ --------------
Enjoy your webpack with django :)
+ .. |Join the chat at https://gitter.im/owais/django-webpack-loader| image:: https://badges.gitter.im/Join%20Chat.svg
+ :target: https://gitter.im/owais/django-webpack-loader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
+ .. |Build Status| image:: https://travis-ci.org/owais/django-webpack-loader.svg?branch=master
+ :target: https://travis-ci.org/owais/django-webpack-loader
+ .. |Coverage Status| image:: https://coveralls.io/repos/owais/django-webpack-loader/badge.svg?branch=master&service=github
+ :target: https://coveralls.io/github/owais/django-webpack-loader?branch=master
+
Keywords: django,webpack,assets
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 2.6
diff --git a/README.md b/README.md
index 4f2c1cf..5d8bb7d 100644
--- a/README.md
+++ b/README.md
@@ -5,17 +5,24 @@
[![Coverage Status](https://coveralls.io/repos/owais/django-webpack-loader/badge.svg?branch=master&service=github)](https://coveralls.io/github/owais/django-webpack-loader?branch=master)
<br>
+
Read http://owaislone.org/blog/webpack-plus-reactjs-and-django/ for a detailed step by step guide on setting up webpack with django using this library.
-<br>
Use webpack to generate your static bundles without django's staticfiles or opaque wrappers.
Django webpack loader consumes the output generated by [webpack-bundle-tracker](https://github.com/owais/webpack-bundle-tracker) and lets you use the generated bundles in django.
+## Maintainers
+In order to overcome the lack of support for Markdown on PyPi, building this package can use [pandoc](http://pandoc.org/installing.html) along with [pypandoc](https://pypi.python.org/pypi/pypandoc) to convert the README.md into a Restructured Text format compatible with PyPI. This requires installing `pandoc` for your operating system (installation instructions on the pandoc site), and `pypandoc` which will be installed if you:
+
+ pip install -r requirements-dev.txt
+
+before uploading to PyPI.
+
+If pandoc or pypandoc fails, the README.md file will be uploaded as it was before this enhancement.
-<br>
## Compatibility
Test cases cover Django>=1.6 on Python 2.7 and Python>=3.3. 100% code coverage is the target so we can be sure everything works anytime. It should probably work on older version of django as well but the package does not ship any test cases for them.
@@ -44,6 +51,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
```
<br>
+
Assuming `assets/` is in `settings.STATICFILES_DIRS` like
```python
@@ -53,6 +61,7 @@ STATICFILES_DIRS = (
```
<br>
+
Assuming your webpack config lives at `./webpack.config.js` and looks like this
```javascript
var path = require("path");
@@ -63,7 +72,7 @@ module.exports = {
context: __dirname,
entry: './assets/js/index',
output: {
- path: path.resolve('./assets/bundles/'),
+ path: path.resolve('./assets/webpack_bundles/'),
filename: "[name]-[hash].js"
},
@@ -75,12 +84,13 @@ module.exports = {
<br>
+
### Default Configuration
```python
WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': not DEBUG,
- 'BUNDLE_DIR_NAME': 'bundles/', # must end with slash
+ 'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
'POLL_INTERVAL': 0.1,
'TIMEOUT': None,
@@ -164,12 +174,12 @@ and your webpack config is located at `/home/src/webpack.config.js`, then the va
## Usage
<br>
-#### Manually run webpack to build assets.
+### Manually run webpack to build assets.
One of the core principles of django-webpack-loader is to not manage webpack itself in order to give you the flexibility to run webpack the way you want. If you are new to webpack, check one of the [examples](https://github.com/owais/django-webpack-loader/tree/master/examples), read [my detailed blog post](http://owaislone.org/blog/webpack-plus-reactjs-and-django/) or check [webpack docs](http://webpack.github.io/).
-#### Settings
+### Settings
Add `webpack_loader` to `INSTALLED_APPS`
@@ -180,7 +190,7 @@ INSTALLED_APPS = (
)
```
-#### Templates
+### Templates
```HTML+Django
{% load render_bundle from webpack_loader %}
@@ -209,7 +219,7 @@ INSTALLED_APPS = (
<br>
-#### Multiple webpack projects
+### Multiple webpack projects
Version 2.0 and up of webpack loader also supports multiple webpack configurations. The following configuration defines 2 webpack stats files in settings and uses the `config` argument in the template tags to influence which stats file to load the bundles from.
@@ -249,7 +259,7 @@ WEBPACK_LOADER = {
</head>
```
-#### File URLs instead of html tags
+### File URLs instead of html tags
If you need the URL to an asset without the HTML tags, the `get_files`
template tag can be used. A common use case is specifying the URL to a
@@ -270,7 +280,7 @@ CKEDITOR.config.contentsCss = '{{ editor_css_files.0.publicPath }}';
</ul>
```
-#### Refer other static assets
+### Refer other static assets
`webpack_static` template tag provides facilities to load static assets managed by webpack
in django templates. It is like django's built in `static` tag but for webpack assets instead.
@@ -292,7 +302,8 @@ In the below example, `logo.png` can be any static asset shipped with any npm or
`./webpack_production.config.js`
```javascript
-config = require('./webpack.config.js');
+var config = require('./webpack.config.js');
+var BundleTracker = require('webpack-bundle-tracker');
config.output.path = require('path').resolve('./assets/dist');
@@ -343,7 +354,7 @@ TEMPLATES = [
Then in your base jinja template:
-```HTML+Jinja2
+```HTML
{{ render_bundle('main') }}
```
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..153f5ae
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,427 @@
+django-webpack-loader
+=====================
+
+|Join the chat at https://gitter.im/owais/django-webpack-loader| |Build
+Status| |Coverage Status|
+
+Read http://owaislone.org/blog/webpack-plus-reactjs-and-django/ for a
+detailed step by step guide on setting up webpack with django using this
+library.
+
+Use webpack to generate your static bundles without django's staticfiles
+or opaque wrappers.
+
+Django webpack loader consumes the output generated by
+`webpack-bundle-tracker <https://github.com/owais/webpack-bundle-tracker>`__
+and lets you use the generated bundles in django.
+
+Maintainers
+-----------
+
+In order to overcome the lack of support for Markdown on PyPi, building
+this package can use `pandoc <http://pandoc.org/installing.html>`__
+along with `pypandoc <https://pypi.python.org/pypi/pypandoc>`__ to
+convert the README.md into a Restructured Text format compatible with
+PyPI. This requires installing ``pandoc`` for your operating system
+(installation instructions on the pandoc site), and ``pypandoc`` which
+will be installed if you:
+
+::
+
+ pip install -r requirements-dev.txt
+
+before uploading to PyPI.
+
+If pandoc or pypandoc fails, the README.md file will be uploaded as it
+was before this enhancement.
+
+Compatibility
+-------------
+
+Test cases cover Django>=1.6 on Python 2.7 and Python>=3.3. 100% code
+coverage is the target so we can be sure everything works anytime. It
+should probably work on older version of django as well but the package
+does not ship any test cases for them.
+
+Install
+-------
+
+.. code:: bash
+
+ npm install --save-dev webpack-bundle-tracker
+
+ pip install django-webpack-loader
+
+ ## Configuration
+
+ ### Assumptions
+
+Assuming ``BASE_DIR`` in settings refers to the root of your django app.
+
+.. code:: python
+
+ import sys
+ import os
+
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+Assuming ``assets/`` is in ``settings.STATICFILES_DIRS`` like
+
+.. code:: python
+
+ STATICFILES_DIRS = (
+ os.path.join(BASE_DIR, 'assets'),
+ )
+
+Assuming your webpack config lives at ``./webpack.config.js`` and looks
+like this
+
+.. code:: javascript
+
+ var path = require("path");
+ var webpack = require('webpack');
+ var BundleTracker = require('webpack-bundle-tracker');
+
+ module.exports = {
+ context: __dirname,
+ entry: './assets/js/index',
+ output: {
+ path: path.resolve('./assets/webpack_bundles/'),
+ filename: "[name]-[hash].js"
+ },
+
+ plugins: [
+ new BundleTracker({filename: './webpack-stats.json'})
+ ]
+ }
+
+Default Configuration
+~~~~~~~~~~~~~~~~~~~~~
+
+.. code:: python
+
+ WEBPACK_LOADER = {
+ 'DEFAULT': {
+ 'CACHE': not DEBUG,
+ 'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash
+ 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
+ 'POLL_INTERVAL': 0.1,
+ 'TIMEOUT': None,
+ 'IGNORE': ['.+\.hot-update.js', '.+\.map']
+ }
+ }
+
+CACHE
+^^^^^
+
+.. code:: python
+
+ WEBPACK_LOADER = {
+ 'DEFAULT': {
+ 'CACHE': not DEBUG
+ }
+ }
+
+When ``CACHE`` is set to True, webpack-loader will read the stats file
+only once and cache the result. This means web workers need to be
+restarted in order to pick up any changes made to the stats files.
+
+BUNDLE\_DIR\_NAME
+^^^^^^^^^^^^^^^^^
+
+.. code:: python
+
+ WEBPACK_LOADER = {
+ 'DEFAULT': {
+ 'BUNDLE_DIR_NAME': 'bundles/' # end with slash
+ }
+ }
+
+``BUNDLE_DIR_NAME`` refers to the dir in which webpack outputs the
+bundles. It should not be the full path. If ``./assets`` is one of you
+static dirs and webpack generates the bundles in
+``./assets/output/bundles/``, then ``BUNDLE_DIR_NAME`` should be
... 1095 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-webpack-loader.git
More information about the Python-modules-commits
mailing list