-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcraco.config.js
74 lines (71 loc) · 1.99 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
const CracoEsbuildPlugin = require('craco-esbuild');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const TerserPlugin = require('terser-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
module.exports = {
plugins: [
{
plugin : CracoEsbuildPlugin,
options: {
esbuildMinimizerOptions: {
target: 'es2020',
css : true,
},
},
},
{
plugin: {
/** @param {{ webpackConfig: import('webpack').Configuration}} config */
overrideWebpackConfig: ({ webpackConfig: config }) => {
config.resolve.plugins = config.resolve.plugins.filter(
plugin => !(plugin instanceof ModuleScopePlugin)
);
const terserPlugin = config.optimization.minimizer.find(m => m instanceof TerserPlugin);
if (terserPlugin) {
terserPlugin.options.minimizer.implementation = TerserPlugin.swcMinify;
delete terserPlugin.options.minimizer.options.warnings;
}
config.plugins.push(
new CopyPlugin({
patterns: [
{ from: 'src/net/message/EQMessage.proto', to: 'proto' },
],
}),
);
config.module.rules.push({
resourceQuery: /raw/,
type : 'asset/source',
});
return config;
}
}
}
],
webpack: {
plugins: {
add : [],
remove: []
},
configure: {
resolve: {
alias: {
react : path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom'),
},
fallback: {
fs : false,
tls : false,
net : false,
path : false,
zlib : false,
http : false,
https : false,
stream: false,
crypto: false,
buffer: require.resolve('buffer/'),
},
},
},
},
};