mini-css-extract-plugin
mini-css-extract-plugin copied to clipboard
How to exclude `css` file by `name`
Feature Proposal
I see that the whole directory is merged to one css file
I use provided example:
const path = require(["path"](https://nodejs.org/api/path.html));
const MiniCssExtractPlugin = require(https://github.com/webpack-contrib/mini-css-extract-plugin);
module.exports = {
entry: {
foo: path.resolve(__dirname, "src/foo"),
bar: path.resolve(__dirname, "src/bar"),
},
optimization: {
splitChunks: {
cacheGroups: {
fooStyles: {
type: "css/mini-extract",
name: "styles_foo",
chunks: (chunk) => {
return chunk.name === "foo";
},
enforce: true,
},
barStyles: {
type: "css/mini-extract",
name: "styles_bar",
chunks: (chunk) => {
return chunk.name === "bar";
},
enforce: true,
},
},
},
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].css",
}),
],
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
],
},
};
And want to filter out nojs.css, but chunk.name give me only cloudcmd, here is my config:
module.exports = {
plugins,
module: {
rules,
},
optimization: {
splitChunks: {
cacheGroups: {
cloudcmdCommon: {
type: "css/mini-extract",
name: "cloudcmd.common",
chunks: (chunk) => {
// I want to not include this files
// return !/css\/(nojs|view|config|terminal|user-menu|columns.*)\.css/.test(name)
console.log(chunk);
return !chunk.name.includes('modules');
},
enforce: true,
},
},
},
},
};
I'm migrating from extract-text-webpack-plugin and try to figure out what I should change in my webpack.config.js.
here is old webpack config
Please help me, I don't think someone on stackoverflow knows how to migrate, migration guide is needed, or better a CodeMode (this is 21 century 😏), I have written a couple, but I need to understand what exactly should be changed to what.