This repository was archived by the owner on Jun 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.api.js
More file actions
63 lines (59 loc) · 1.7 KB
/
node.api.js
File metadata and controls
63 lines (59 loc) · 1.7 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
61
62
63
const { getLocalIdent } = require('css-loader/dist/utils');
const ExtractCssChunks = require('extract-css-chunks-webpack-plugin');
module.exports.default = () => {
return {
webpack(config, { stage }) {
const styleLoader = {
loader: require.resolve('style-loader'),
};
const cssLoader = {
loader: require.resolve('css-loader'),
options: {
modules: true,
importLoaders: 2,
localIdentName: '[name]-[local]_[hash:base64:4]',
getLocalIdent: (context, localIdentName, localName, options) =>
context.resourcePath.includes('/node_modules/')
? localName
: getLocalIdent(context, localIdentName, localName, options),
},
};
const postcssLoader = {
loader: require.resolve('postcss-loader'),
options: {
plugins: [
require('postcss-flexbugs-fixes'),
require('autoprefixer')({
flexbox: 'no-2009',
}),
],
},
};
const sassLoader = {
loader: require.resolve('sass-loader'),
};
config.module.rules[0].oneOf.unshift({
test: /\.scss$/,
use: {
dev: [styleLoader, cssLoader, postcssLoader, sassLoader],
node: [
extendOptions(cssLoader, { exportOnlyLocals: true }),
postcssLoader,
sassLoader,
],
prod: [ExtractCssChunks.loader, cssLoader, postcssLoader, sassLoader],
}[stage],
});
return config;
},
};
function extendOptions(loader, options) {
return {
...loader,
options: {
...loader.options,
...options,
},
};
}
};