-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcraco.config.cjs
More file actions
76 lines (66 loc) · 1.8 KB
/
craco.config.cjs
File metadata and controls
76 lines (66 loc) · 1.8 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
64
65
66
67
68
69
70
71
72
73
74
75
76
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const CracoAlias = require("craco-alias");
const isProductionBuild = process.env.NODE_ENV === "production";
const shouldAnalyze = process.env.REACT_APP_RUN_ANALYZER === "true";
const plugins = [];
if (isProductionBuild && shouldAnalyze) {
plugins.push(new BundleAnalyzerPlugin({ analyzerMode: "server" }));
}
module.exports = {
plugins: [
{
plugin: CracoAlias,
options: {
source: "options",
baseUrl: "./",
aliases: {
"txml/txml": "./node_modules/txml/dist/txml",
},
},
},
],
webpack: {
plugins,
configure: (webpackConfig) => {
if (isProductionBuild) {
webpackConfig.devtool = false;
}
webpackConfig.module.rules.forEach((rule) => {
if (rule.oneOf) {
rule.oneOf.forEach((subRule) => {
if (subRule.use && Array.isArray(subRule.use)) {
subRule.use = subRule.use.filter(
(u) =>
!(
typeof u === "object" &&
u.loader &&
u.loader.includes("thread-loader")
)
);
}
});
}
});
webpackConfig.plugins = webpackConfig.plugins.filter(
(plugin) => plugin.constructor.name !== "ForkTsCheckerWebpackPlugin"
);
webpackConfig.optimization.splitChunks = {
chunks: "all",
maxInitialRequests: Infinity,
minSize: 20000,
};
webpackConfig.module.rules.push({
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
});
webpackConfig.module.parser = {
javascript: {
exportsPresence: false,
},
};
return webpackConfig;
},
},
};