Skip to content
This repository was archived by the owner on Oct 16, 2021. It is now read-only.

Commit d9b60e4

Browse files
committed
feat: improve the cacheability of the vendor bundle
BREAKING CHANGE: The webpack runtime has moved into a separate file. Therefore you need to add a reference to that file into your HTML / Handlebars file(s) before the vendor bundle: ```html <!-- webpack runtime JS --> @@runtime.js <!-- Vendor JS --> @@vendor.js <!-- Own JS --> @@app.js ``` See <https://developers.google.com/web/fundamentals/performance/webpack/use-long-term-caching#webpack_runtime_code> for details about the why.
1 parent 088fc56 commit d9b60e4

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

app/templates/build/webpack/config.optimization.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import UglifyJSPlugin from 'uglifyjs-webpack-plugin';
22

33
export const optimization = {
4+
runtimeChunk: {
5+
name: 'runtime'
6+
},
47
splitChunks: {
58
cacheGroups: {
69
commons: {

app/templates/build/webpack/config.plugins.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const devPlugins = [
7979
* Plugins used for production builds only
8080
*/
8181
const prodPlugins = [
82+
new webpack.HashedModuleIdsPlugin(),
8283
new ImageminPlugin({test: /\.(jpe?g|png|gif|svg)$/i}),
8384
configFile.purifyCSS.usePurifyCSS ? new PurifyCSSPlugin(purifyCSSOptions) : false,
8485
generateBanners ? new webpack.BannerPlugin({

app/templates/src/handlebars/layouts/_default.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
{{{contents}}}
3434
<!-- end: content -->
3535

36+
<!-- webpack runtime JS -->
37+
@@runtime.js
38+
3639
<!-- Vendor JS -->
3740
@@vendor.js
3841

0 commit comments

Comments
 (0)