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
{{ message }}
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
extract multiple css files but created a unnecessary js file. #279
I want to extract multiple css files base on "src" and "node_modules" paths with specific output path.
I try to use splitChunks.cacheGroups but it create two files whitin js and css folders.
I don't need the xxx.styles.js file, it's unnecessary. how could I fix it? thanks.
@michael-ciniawsky It isn't webpack bug. I think MiniCssExtractPlugin should remove assets.
After almost 1 year the problem exists... :) Guys, you can resolve it by adding simple plugin, like this:
plugins: [newHtmlWebpackPlugin({template: resolve(SRC_DIR,'./index.html'),inject: 'head',minify: IS_PRODUCTION,hash: true,}),newMiniCssExtractPlugin({filename: '[name].css',hmr: !IS_PRODUCTION,}),{apply(compiler){compiler.hooks.shouldEmit.tap('Remove styles from output',(compilation)=>{deletecompilation.assets['styles.js'];// Remove asset. Name of file depends of your entries and returntrue;})}}],
Reacted by Dimitar Spassov, Agus Rdz, Radovan Šmitala, Mostafa Rahmati, Sander Nemvalts, JC Gonzalez, Jaroslav Kondela, Tom Délié and Akihiro Oyamada
@michael-ciniawsky It isn't webpack bug. I think MiniCssExtractPlugin should remove assets.
After almost 1 year the problem exists... :) Guys, you can resolve it by adding simple plugin, like this:
plugins: [newHtmlWebpackPlugin({template: resolve(SRC_DIR,'./index.html'),inject: 'head',minify: IS_PRODUCTION,hash: true,}),newMiniCssExtractPlugin({filename: '[name].css',hmr: !IS_PRODUCTION,}),{apply(compiler){compiler.hooks.shouldEmit.tap('Remove styles from output',(compilation)=>{deletecompilation.assets['styles.js'];// Remove asset. Name of file depends of your entries and returntrue;})}}],
the file is no longer created, but a tag with the path to the file is generated.
@michael-ciniawsky It isn't webpack bug. I think MiniCssExtractPlugin should remove assets.
After almost 1 year the problem exists... :) Guys, you can resolve it by adding simple plugin, like this:
plugins: [newHtmlWebpackPlugin({template: resolve(SRC_DIR,'./index.html'),inject: 'head',minify: IS_PRODUCTION,hash: true,}),newMiniCssExtractPlugin({filename: '[name].css',hmr: !IS_PRODUCTION,}),{apply(compiler){compiler.hooks.shouldEmit.tap('Remove styles from output',(compilation)=>{deletecompilation.assets['styles.js'];// Remove asset. Name of file depends of your entries and returntrue;})}}],
causes
(node:17584) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
@michael-ciniawsky It isn't webpack bug. I think MiniCssExtractPlugin should remove assets.
After almost 1 year the problem exists... :) Guys, you can resolve it by adding simple plugin, like this:
plugins: [
new HtmlWebpackPlugin({
template: resolve(SRC_DIR, './index.html'),
inject: 'head',
minify: IS_PRODUCTION,
hash: true,
}),
new MiniCssExtractPlugin({
filename: '[name].css',
hmr: !IS_PRODUCTION,
}),
{
apply(compiler) {
compiler.hooks.shouldEmit.tap('Remove styles from output', (compilation) => {
delete compilation.assets['styles.js']; // Remove asset. Name of file depends of your entries and
return true;
})
}
}
],
causes
(node:17584) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
Activity
[-]How to extract multiple css files?[/-][+]extract multiple css files but created a unnecessary js file.[/+]michael-ciniawsky commentedon Sep 19, 2018
It's a known bug in
webpackitself webpack/webpack#1967 && https://github.com/webpack/webpack/projects/5 (Yes Column 2nd Card)vyushin commentedon Aug 25, 2019
@michael-ciniawsky It isn't webpack bug. I think MiniCssExtractPlugin should remove assets.
After almost 1 year the problem exists... :) Guys, you can resolve it by adding simple plugin, like this:
Devinora commentedon Feb 16, 2020
the file is no longer created, but a tag with the path to the file is generated.
zanderwar commentedon Nov 2, 2020
causes
lwr commentedon Jun 23, 2025
But we have https://webpack.js.org/api/compilation-object/#deleteasset