forked from gorilla-devs/GDLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
98 lines (93 loc) · 2.58 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
// const path = require("path");
// const alias = {
// app: path.resolve("./src/app/"),
// common: path.resolve("./src/common/"),
// ui: path.resolve("./src/ui/")
// };
const CracoAntDesignPlugin = require('craco-antd');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = ({ env }) => {
const isEnvDevelopment = env === 'development';
const isEnvProduction = env === 'production';
return {
babel: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: '13'
}
}
],
'@babel/react'
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-transform-runtime',
'@babel/plugin-syntax-dynamic-import',
'@loadable/babel-plugin',
'babel-plugin-macros',
[
'babel-plugin-styled-components',
{
ssr: true,
pure: true
}
]
]
},
webpack: {
devtool: 'eval-cheap-module-source-map',
configure: {
devtool: 'eval-cheap-module-source-map',
target:
process.env.APP_TYPE === 'electron' ? 'electron-renderer' : 'web',
optimization: {
splitChunks: {
name: false,
chunks: 'all',
maxInitialRequests: Infinity,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]!(antd)/,
name(module) {
// get the name. E.g. node_modules/packageName/not/this/part.js
// or node_modules/packageName
const packageName = module.context.match(
/[\\/]node_modules[\\/](.*?)([\\/]|$)/
)[1];
// npm package names are URL-safe, but some servers don't like @ symbols
return `npm.${packageName.replace('@', '')}`;
}
}
}
}
},
output: {
filename: isEnvProduction
? 'static/js/[name].js'
: isEnvDevelopment && 'static/js/bundle.js',
chunkFilename: isEnvProduction
? 'static/js/[name].chunk.js'
: isEnvDevelopment && 'static/js/[name].chunk.js'
}
},
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
sourceMap: true,
cache: true
})
]
}
},
plugins: [
{
plugin: CracoAntDesignPlugin
}
]
};
};