-
Notifications
You must be signed in to change notification settings - Fork 643
Expand file tree
/
Copy pathwebpack.scss.js
More file actions
60 lines (59 loc) · 1.69 KB
/
Copy pathwebpack.scss.js
File metadata and controls
60 lines (59 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = (options, apos, srcBuildNames) => {
return {
module: {
rules: [
{
test: /\.s[ac]ss$/,
use: [
// Instead of style-loader, to avoid FOUC
MiniCssExtractPlugin.loader,
// Parses CSS imports and make css-loader ignore urls. Urls will still be handled by webpack
{
loader: 'css-loader',
options: { url: false }
},
// Provides autoprefixing
{
loader: 'postcss-loader',
options: {
sourceMap: true,
postcssOptions: {
plugins: [
[
'autoprefixer',
{}
]
]
}
}
},
// Parses SASS imports
{
loader: 'sass-loader',
options: {
sassOptions: {
// Without this Sass emits a BOM, which postcss 8.5.24+ keeps.
// A BOM in the middle of a stylesheet kills the rule after it.
charset: false
}
}
}
],
// https://stackoverflow.com/a/60482491/389684
sideEffects: true
}
]
},
plugins: [
new MiniCssExtractPlugin({
// Should be automatic but we wind up with main.css if we try to go with that
filename: ({ chunk }) => {
return srcBuildNames.includes(chunk.name)
? '[name].css'
: '[name]-bundle.css';
}
})
]
};
};