-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
craco.config.js
59 lines (54 loc) · 1.47 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
const { getLoader, loaderByName, throwUnexpectedConfigError } = require("@craco/craco");
module.exports = {
babel : {
plugins : ["@babel/plugin-transform-optional-chaining"],
},
webpack : {
alias : {
"../../theme.config$" : require("path").join(__dirname, "/src/semantic-ui/theme.config"),
},
},
plugins : [
{
plugin : require("craco-less"),
options : {
lessLoaderOptions : {
javascriptEnabled : true,
},
},
},
{
plugin : {
overrideWebpackConfig({ context, webpackConfig }) {
const { isFound, match: fileLoaderMatch } = getLoader(
webpackConfig,
loaderByName("file-loader"),
);
if (!isFound) {
throwUnexpectedConfigError({
message : `Can't find file-loader in the ${context.env} webpack config!`,
});
}
fileLoaderMatch.loader.exclude.push(/theme.config$/);
fileLoaderMatch.loader.exclude.push(/\.variables$/);
fileLoaderMatch.loader.exclude.push(/\.overrides$/);
if (["development", "staging"].indexOf(process.env.REACT_APP_ENV) !== -1) {
webpackConfig.mode = "development";
webpackConfig.optimization.minimize = false;
webpackConfig.optimization.runtimeChunk = false;
webpackConfig.optimization.splitChunks = {
cacheGroups : {
default : false,
},
};
webpackConfig.output.filename = "[name].js";
}
return webpackConfig;
},
},
},
],
eslint : {
enable : false,
},
};