-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcraco.config.js
100 lines (97 loc) · 2.8 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const CracoLessPlugin = require("craco-less");
const path = require("path");
const { whenProd,getPlugin,pluginByName } = require("@craco/craco");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
webpack: {
alias: {
"@": path.join(__dirname, "./src"),
},
plugins: [
...whenProd(
() => [
new TerserPlugin({
sourceMap: false,
terserOptions: {
ecma: undefined,
warnings: false,
parse: {},
compress: {
drop_console: process.env.NODE_ENV === "production",
drop_debugger: false,
pure_funcs: process.env.NODE_ENV === "production" ? ["console.log"] : "",
},
},
}),
],
[]
),
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
chunks: "initial",
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
},
vendor: {
test: /node_modules/,
chunks: "initial",
name: "vendor",
priority: 10,
enforce: true,
},
},
},
},
// configure: (webpackConfig, { env, paths }) => {
// if (process.env.NODE_ENV === "production") {
// webpackConfig.externals = {
// react: "React",
// "react-dom": "ReactDOM",
// redux: "Redux",
// "video.js":"videojs"
// };
// cdn = {
// js: [
// "https://cdn.bootcdn.net/ajax/libs/react/17.0.2/umd/react.production.min.js",
// "https://cdn.bootcdn.net/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js",
// "https://cdn.bootcdn.net/ajax/libs/redux/4.1.0/redux.min.js",
// "https://unpkg.com/[email protected]/dist/video.min.js",
// ],
// css: [
// "https://unpkg.com/[email protected]/dist/video-js.min.css"
// ],
// };
// const { isFound, match } = getPlugin(webpackConfig, pluginByName("HtmlWebpackPlugin"));
// if (isFound) {
// match.options.cdn = cdn;
// }
// }
// return webpackConfig;
// },
},
babel: {
plugins: [
["import", { libraryName: "antd", libraryDirectory: "es", style: true }],
["@babel/plugin-proposal-decorators", { legacy: true }],
],
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: {
"@primary-color": "#428BE5",
},
javascriptEnabled: true,
},
},
},
},
],
};