This project has been archived by its maintainers, and is no longer receiving any updates.
Django Webpack Bridge
Creates a bridge from webpack to django.
How to Use
-
Add
django-webpack-bridgetosetup.pyorpyproject.toml, andpackage.json. -
Add the plugin to
webpack.config.jsconst DjangoBridgePlugin = require('django-webpack-bridge'); module.exports = { ..., plugins: [ ..., new DjangoBridgePlugin(), ], }
django-webpack-bridgewill use the variables frommodule.exports.output -
Add the following to
settings.pyINSTALLED_APPS += [ 'webpack_bridge', ] STATICFILES_DIRS = [ '{same as module.exports.output.path from webpack.config.js}', ]
-
In the
template.html{% load webpack_bridge %} {% render_webpack_entry 'entry point name' js='defer' %}
Settings
BRIDGE_SETTINGS = {
# Name of the manifest file
'manifest_file': 'manifest.json',
# Boolean to turn caching on and off
'cache': not settings.DEBUG,
# Timeout duration for the cache
'cache_timeout': 86400, # 1 Day
# Namespace for the cache
'cache_prefix': 'webpack_manifest',
# Maps a tag group to a group of tags
'group_to_extensions': {
'script': ('js', ),
'style': ('css', ),
},
# Maps a tag group to a html tag
'group_to_html_tag': {
'script': '<script src="{path}" {attributes}></script>',
'style':
'<link rel="stylesheet" type="text/css"'
+ ' href="{path}" {attributes}>',
},
# Time between updaing the manifest from the file while compiling
'compiling_poll_duration': 0.5,
}
group_to_extensions and group_to_html_tag combine to create a multi-key map from a group of file extensions to a html tag. Eg. (js, jsx) -> <script src="{path}" {attributes}></script>
path: Will be replaced with the bundle path
attributes: Will be replaced with any attributes specfied when when calling 'render_webpack_entry'. Attributes are grouped by file extension
The following settings can be passed to DjangoBridgePlugin
{
path: 'defaults to module.exports.output.path',
publicPath: 'defaults to module.exports.output.publicPath',
fileName: 'defaults to manifest.json',
}
Development
Running tests
- Create and activate a python virtual env of your choice (optional).
- Run
pip install . - Run
DJANGO_SETTINGS_MODULE=test_files.settings python -m django test webpack_bridge
Running the Demo
- Run
docker-compose up --build - Open
localhost:8000
Metadata
Release files for django-webpack-bridge 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-webpack-bridge-0.1.4.tar.gz | 8.4 kB | Without provenance | Details for django-webpack-bridge-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_webpack_bridge-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for django_webpack_bridge-0.1.4-py3-none-any.whl |
Total release size: 20.3 kB
Release files / django-webpack-bridge-0.1.4.tar.gz
| Download URL | django-webpack-bridge-0.1.4.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9675d7e65673186a6d59f43527d64df6735cbd7ddb9f045ca7052b1dc093e811
|
|
BLAKE2b-256 checksum How to use checksums |
e9e68f54ee3d3b89b4874cc13bd4105b8a767f5a8170b288faedea815da14bd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Release files / django_webpack_bridge-0.1.4-py3-none-any.whl
| Download URL | django_webpack_bridge-0.1.4-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2980984c3b19e5b106c89d3b361cefc9411478794e8b489b398859577aa3235
|
|
BLAKE2b-256 checksum How to use checksums |
56dfb166a716df36e3bba063ae120292d7ebebd63231101b5cdd2fe3b961a16a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|
Security for django-webpack-bridge 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.