forked from WindRunnerMax/DocEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
42 lines (39 loc) · 1.25 KB
/
config-overrides.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
const { override, disableEsLint, addLessLoader } = require("customize-cra");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const rewiredESbuild = require("react-app-rewired-esbuild");
// https://github.com/arackaf/customize-cra
const configWebpackPlugins = () => config => {
// 太卡关闭一些插件
// 关闭`ESLINT`的插件 -> 在`VSCode`校验
// 关闭`CaseSensitivePathsPlugin`插件
// 关闭`IgnorePlugin`插件
config.plugins = config.plugins.filter(
plugin =>
plugin.constructor.name !== "ESLintWebpackPlugin" &&
plugin.constructor.name !== "CaseSensitivePathsPlugin" &&
plugin.constructor.name !== "IgnorePlugin"
);
// 添加插件
process.env.NODE_ENV === "production" &&
config.plugins.push(
new UglifyJsPlugin({
uglifyOptions: {
compress: { drop_debugger: true, drop_console: true },
},
})
);
return config;
};
const configEmpty = config => config;
module.exports = {
webpack: override(
process.env.NODE_ENV === "development" ? rewiredESbuild() : configEmpty,
addLessLoader({
javascriptEnabled: true,
importLoaders: true,
localIdentName: "[name]__[hash:base64:5]",
}),
disableEsLint(),
configWebpackPlugins()
),
};