Skip to content

Commit efb6134

Browse files
Angular: Update MiniCssExtractPlugin configuration for cache busting
1 parent ad8a398 commit efb6134

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

code/frameworks/angular/src/server/framework-preset-angular-cli.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ export async function webpackFinal(baseConfig: webpack.Configuration, options: P
3535

3636
webpackConfig.plugins = webpackConfig.plugins ?? [];
3737

38+
// Change the generated css filename to include the contenthash for cache busting
39+
const miniCssPlugin = webpackConfig?.plugins?.find(
40+
(plugin: any) => plugin?.constructor?.name === 'MiniCssExtractPlugin'
41+
) as any;
42+
43+
if (miniCssPlugin && 'options' in miniCssPlugin) {
44+
miniCssPlugin.options.filename = '[name].[contenthash].css';
45+
miniCssPlugin.options.chunkFilename = '[name].iframe.[contenthash].css';
46+
}
47+
3848
webpackConfig.plugins.push(
3949
new WebpackDefinePlugin({
4050
STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({

0 commit comments

Comments
 (0)