-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
57 lines (55 loc) · 1.81 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
const webpack = require('webpack');
module.exports = {
webpack: {
configure: (webpackConfig) => {
const wasmExtensionRegExp = /\.wasm$/;
webpackConfig.resolve.extensions.push('.wasm');
webpackConfig.experiments = {
asyncWebAssembly: true,
syncWebAssembly: true,
topLevelAwait: true,
};
webpackConfig.resolve.fallback = {
...webpackConfig.resolve.fallback,
fs: false, // fs is not typically available in the browser
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
util: require.resolve('util'),
os: require.resolve('os-browserify/browser'),
path: require.resolve('path-browserify'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
net: false, // net is not typically available in the browser
tls: false, // tls is not typically available in the browser
dns: require.resolve('dns.js'),
zlib: require.resolve('browserify-zlib'),
url: require.resolve('url'),
buffer: require.resolve('buffer/'),
assert: require.resolve('assert/'),
dgram: false, // dgram is not typically available in the browser
process: require.resolve('process'),
};
webpackConfig.module.rules.forEach((rule) => {
(rule.oneOf || []).forEach((oneOf) => {
if (oneOf.type === 'asset/resource') {
oneOf.exclude.push(wasmExtensionRegExp);
}
});
});
webpackConfig.plugins.push(
new webpack.ProvidePlugin({
process: 'process',
Buffer: ['buffer', 'Buffer'],
})
);
return webpackConfig;
},
},
jest: {
configure: {
globals: {
CONFIG: true,
},
},
},
};