You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a setting to configure skip common chunks behaviour globally
You can now specify a 'SKIP_COMMON_CHUNKS' setting globally for each
Webpack configuration. This will perform the same 'skip_common_chunks'
logic from the 'render_bundle' template tag without having to add
a parameter to every tag.
To maintain backwards compatibility we default to 'False' and allow
common chunks to be rendered to the HTML document as script tags. In the
future, it will be easy to change this default behaviour if desired.
I've added test coverage to ensure that the global setting can be
override by the existing template tag parameter and that we maintain
backwards compatibility.
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,6 +111,8 @@ The `STATS_FILE` parameter represents the output file produced by `webpack-bundl
111
111
112
112
-`LOADER_CLASS` is the fully qualified name of a python class as a string that holds the custom webpack loader. This is where behavior can be customized as to how the stats file is loaded. Examples include loading the stats file from a database, cache, external url, etc. For convenience, `webpack_loader.loader.WebpackLoader` can be extended. The `load_assets` method is likely where custom behavior will be added. This should return the stats file as an object.
113
113
114
+
-`SKIP_COMMON_CHUNKS` is a flag which prevents already generated chunks from being included again in the same page. This should only happen if you use more than one entrypoint per Django template (multiple `render_bundle` calls). By enabling this, you can get the same default behavior of the [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/). The same caveats apply as when using `skip_common_chunks` on `render_bundle`, see that section below for more details.
115
+
114
116
Here's a simple example of loading from an external url:
115
117
116
118
```py
@@ -239,7 +241,7 @@ The public path is based on `webpack.config.js` [output.publicPath](https://webp
239
241
Please note that this approach will use the original asset file, and not a post-processed one from the Webpack pipeline, in case that file had gone through such flow (i.e.: You've imported an image on the React side and used it there, the file used within the React components will probably have a hash string on its name, etc. This processed file will be different than the one you'll grab with `webpack_static`).
240
242
241
243
### Use `skip_common_chunks` on `render_bundle`
242
-
You can use the parameter `skip_common_chunks=True`to specify that you don't want an already generated chunk be included again in the same page. This should only happen if you use more than one entrypoint per Django template (multiple `render_bundle` calls). By using `skip_common_chunks=True`, you can get the same default behavior of the [HtmlWebpackPlugin](https://webpack.js.org/plugins/html-webpack-plugin/).
244
+
You can use the parameter `skip_common_chunks=True`or `skip_common_chunks=False` to override the global `SKIP_COMMON_CHUNKS` setting for a specific bundle.
243
245
244
246
In order for this option to work, `django-webpack-loader` requires the `request` object to be in the context, to be able to keep track of the generated chunks.
0 commit comments