Argument: bool, inherits, default
If True the server will re-read the stats file for each request and requests will block while webpack is running. See webpack.timeout to configure how long the requests will wait for webpack.
Argument: bool, default
If True, pyramid_webpack will automatically set up the static view(s) for you.
Disable this if you want to call
add_static_view yourself (e.g. if you need
to pass in custom parameters).
The directory that contains the compiled webpack bundles. This may be in three forms:
raw_relative_path- This path will be relative to your root project package
package:relative_path- This is a path relative to a package location
/absolute/path- An absolute path on disk
You will almost always need to supply a bundle_dir, but if you are using an
external webserver for
webpack.static_view_name, then you don’t need to
Argument: str, default
This will be the
name argument passed to add_static_view.
Argument: str, default
The location of the webpack stats file generated by the webpack-bundle-tracker
plugin. This path may be in the same three formats as
Argument: float, inherits, default
Requests will block for this many seconds while waiting for webpack to finish
webpack.debug = True). A value of
0 will wait
Argument: list, inherits, default
When getting a bundle, ignore chunks that match these patterns. Uses glob matching.
Argument: list, inherits
When getting a bundle, ignore chunks that match these patterns. Uses PCRE matching.
List of names of other webpack configurations to load. See the section below for more detail.
If you have multiple instances of webpack running and generating bundles, you
can load them as well by giving them names and adding them to the
webpack.configs option. You can then configure those instances by prefixing
the same options in the config file with
webpack.<name>.. For example:
webpack.debug = True webpack.bundle_dir = webpack/bundles webpack.stats_file = webpack/stats.json webpack.configs = other webpack.other.bundle_dir = webpack/other/bundles webpack.other.stats_fie = webpack/other/stats.json
For any of the options that are marked as
inherits (for example,
webpack.debug), it will default to whatever value was provided to the
default configuration. For example, the value of
webpack.other.debug in the
above example will default to
webpack.debug = True.
For information on how to render bundles from different configs, see the docs on Rendering bundles into templates.
Static View Examples¶
Here we’ll go over a couple of example configurations for the asset static views and how they differ.
The simplest version can be used in development or production, and will serve the static assets using pyramid:
webpack.bundle_dir = webpack/bundles
If you’re running in production and want to serve the assets from a CDN, you can instead use a static_view_name:
# Don't need a webpack.bundle_dir webpack.static_view_name = //my.cdn.com/
And if you want to full control over how the static views are set up, you can disable them:
webpack.static_view = False
And set it up yourself:
for config_name, state in config.registry.webpack.iteritems(): # You should use state.static_view_path as the path. # That value is used to generate the urls via request.static_url() config.add_static_view(name="//my.cdn.com/" + config_name, path=state.static_view_path, cache_max_age=64000)