-
Notifications
You must be signed in to change notification settings - Fork 10
/
craco.config.js
47 lines (46 loc) · 1.34 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
const webpack = require('webpack')
module.exports = {
jest: {
configure: {
globals: {
CONFIG: true,
},
},
},
webpack: {
plugins: {
add: [
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
}),
new webpack.IgnorePlugin({
checkResource(resource) {
return /.*\/wordlists\/(?!english).*\.json/.test(resource)
},
}),
],
remove: ['ModuleScopePlugin'],
},
configure: (webpackConfig) => {
const scopePluginIndex = webpackConfig.resolve.plugins.findIndex(
({ constructor }) => constructor && constructor.name === 'ModuleScopePlugin',
)
webpackConfig.resolve.plugins.splice(scopePluginIndex, 1)
webpackConfig.resolve.fallback = {
buffer: require.resolve('buffer'),
path: require.resolve('path-browserify'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
vm: require.resolve('vm-browserify'),
fs: false,
}
webpackConfig.experiments = { asyncWebAssembly: true }
webpackConfig.module.rules
.find((i) => 'oneOf' in i)
.oneOf.find((i) => i.type === 'asset/resource')
.exclude.push(/\.wasm$/);
return webpackConfig
}
}
}