Closed
Description
I've the follow example configuration to use mini-css-extract-plugin with Webpack 4:
entry: {
a: ['./js/a.js', './scss/a.scss'],
b: ['./js/b.js', './scss/b.scss']
},
module: {
rules: [
[...],
{
test: /\.(css|sass|scss)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 2,
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: () => [
require('autoprefixer')
],
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
js: {
test: /\.js$/,
name: "commons",
chunks: "all",
minChunks: 7,
},
css: {
test: /\.(css|sass|scss)$/,
name: "commons",
chunks: "all",
minChunks: 2,
}
}
}
},
plugins: [
new MiniCssExtractPlugin({
filename: "dist/[name].css",
}),
]
And the following sass files:
// a.scss
@import 'global.scss';
@import 'vendor.css';
[...]
// b.scss
@import 'global.scss';
@import 'vendor.css';
[...]
When I run webpack vendor.css
is inserted in in commons.css
bundle while global.scss
not.
In general every import of .css
file get processed by splitChunks option (only if extension .css
is specified in the name) while .scss
files not.
I have a project with multiple sass entry point and many @import of sass component and I'd like to create a common bundle with shared sass modules.
The chunk of js files works properly.
Metadata
Metadata
Assignees
Labels
No labels