-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
67 lines (50 loc) · 1.43 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
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
const {
override,
fixBabelImports,
addWebpackAlias,
addPostcssPlugins,
} = require("customize-cra");
const path = require("path");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); //生产环境打包-去除console.log、debugger;
const myPlugin = [
new UglifyJsPlugin({
// 开启打包缓存
cache: true,
// 开启多线程打包
parallel: true,
uglifyOptions: {
warnings: false, // 删除警告
compress: {
drop_debugger: true, // 移除debugger
drop_console: true, // 移除console
},
},
}),
];
module.exports = override(
fixBabelImports("import", {
//配置按需加载
libraryName: "antd",
libraryDirectory: "es",
style: true,
}),
//addWebpackExternals({ //不做打包处理配置,如直接以cdn引入的
// echarts: "window.echarts",
// // highcharts:"window.highcharts"
// }),
addWebpackAlias({
//路径别名
"@": path.resolve(__dirname, "src"),
}),
addPostcssPlugins([require("tailwindcss"), require("autoprefixer")]),
(config) => {
//暴露webpack的配置 config ,evn
// 去掉打包生产map 文件
config.devtool =
config.mode === "development" ? "cheap-module-source-map" : false;
if (process.env.NODE_ENV === "production") config.devtool = false;
if (process.env.NODE_ENV !== "development")
config.plugins = [...config.plugins, ...myPlugin];
return config;
}
);