Skip to content

Instantly share code, notes, and snippets.

@NateScarlet
Last active April 4, 2020 15:30
Show Gist options
  • Save NateScarlet/48f2bd40299c9c72b50a12fbd946b94c to your computer and use it in GitHub Desktop.
Save NateScarlet/48f2bd40299c9c72b50a12fbd946b94c to your computer and use it in GitHub Desktop.
Use html-webpack-plugin to generate stats.json
new HtmlPlugin({
/** @param {{compilation: import('webpack').compilation.Compilation}} */
templateContent: ({ compilation }) => {
const {
hash,
publicPath,
assetsByChunkName,
assets,
} = compilation.getStats().toJson({ all: true }, true);
return JSON.stringify(
{ hash, publicPath, assetsByChunkName, assets },
undefined,
4
);
},
inject: false,
minify: false,
filename: "stats.json",
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment