-
Notifications
You must be signed in to change notification settings - Fork 1
/
craco.config.js
61 lines (54 loc) · 2.04 KB
/
craco.config.js
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
const path = require('path'); //eslint-disable-line @typescript-eslint/no-var-requires
const cssLoader = require.resolve('css-loader');
const sassRegex = /\.(scss|sass)$/;
const sassModuleRegex = /\.module\.(scss|sass)$/;
const resolve = (dir) => path.resolve(__dirname, dir);
module.exports = {
reactScriptsVersion: 'react-scripts', // {default value}
style: {
sass: {
modules: {
exportLocalsConvention: 'camelCase'
}
}
},
webpack: {
alias: {
'@ra': resolve('src/vendor/react-arsenal')
},
configure: (webpackConfig) => {
webpackConfig.module.rules = webpackConfig.module.rules.map((rule) => {
if (!Array.isArray(rule.oneOf)) {
return rule;
}
rule.oneOf = rule.oneOf
.map((loader) => {
// remove non module loaders
if (String(loader.test) === String(sassRegex)) {
return null;
}
// match non .module.scss files with the configuration for scss modules
if (String(loader.test) === String(sassModuleRegex)) {
loader.test = sassRegex;
}
loader.use?.forEach((styleLoader) => {
if (styleLoader.loader !== cssLoader) {
return;
}
styleLoader.options.modules.exportLocalsConvention = 'camelCaseOnly';
});
return loader;
})
.filter(Boolean);
return rule;
});
return webpackConfig;
}
},
babel: {
plugins: process.env.NODE_ENV !== 'development' ? ['transform-remove-console'] : [],
loaderOptions: {
ignore: ['./node_modules/mapbox-gl/dist/mapbox-gl.js']
}
}
};