Manifest loader that allows you to include references to files built by webpack.
Handles manifests generated by the webpack-yam-plugin.
If you're using this in a project, use pip
pip install webpack-manifest
If you're using this in an app or library, just copy the loader's file in so that you can avoid causing any dependency pains downstream.
If you installed with pip, import it with
import webpack_manifest from webpack_manifestIf you copied the source file in, import it with
import webpack_manifestOnce you've imported the manifest loader...
manifest = webpack_manifest.load(
# An absolute path to a manifest file
path='/abs/path/to/manifest.json',
# The root url that your static assets are served from
static_url='/static/',
# optional args...
# ----------------
# Ensures that the manifest is flushed every time you call `load(...)`
# If webpack is currently building, it will also delay until it's ready.
# You'll want to set this to True in your development environment
debug=False,
# Max timeout (in seconds) that the loader will wait while webpack is building.
# This setting is only used when the `debug` argument is True
timeout=60,
)
# `load` returns a manifest object with properties that match the names of
# the entries in your webpack config. The properties matching your entries
# have `js` and `css` properties that are pre-rendered strings that point
# to all your JS and CSS assets. Additionally, tuples of relative urls are
# available under `rel_js` and `rel_css` properties.
# A string containing pre-rendered script elements for the "main" entry
manifest.main.js # '<script src="/static/path/to/file.js"><script><script ... >'
# A string containing pre-rendered link elements for the "main" entry
manifest.main.css # '<link rel="stylesheet" href="/static/path/to/file.css"><link ... >'
# A string containing pre-rendered link elements for the "vendor" entry
manifest.vendor.css # '<link rel="stylesheet" href="/static/path/to/file.css"><link ... >'
# A tuple containing relative urls (without the static url) to the "vender" entry
manifest.vendor.rel_css # ('path/to/file.css', 'path/to/another.css', ...)
# Note: If you don't name your entry, webpack will automatically name it "main".