-
Notifications
You must be signed in to change notification settings - Fork 1
/
config-overrides.js
53 lines (51 loc) · 1.83 KB
/
config-overrides.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
const webpack = require('webpack');
module.exports = function override(config, env) {
config.resolve.fallback = {
buffer: require.resolve('buffer'),
util: require.resolve('util'),
fs: require.resolve('graceful-fs'),
path: require.resolve('path-browserify'),
url: require.resolve('url'),
stream: require.resolve('stream-browserify'),
constants: require.resolve('constants-browserify'),
zlib: require.resolve('browserify-zlib'),
'process/browser': require.resolve('process/browser'),
os: require.resolve('os-browserify/browser'),
};
config.plugins.push(
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
const mod = resource.request.replace(/^node:/, '');
switch (mod) {
case 'buffer':
resource.request = 'buffer';
break;
case 'util':
resource.request = 'util';
break;
case 'fs':
resource.request = 'fs';
break;
case 'path':
resource.request = 'path';
break;
case 'stream':
resource.request = 'readable-stream';
break;
case 'url':
resource.request = 'url';
break;
case 'zlib':
resource.request = 'zlib';
break;
default:
throw new Error(`Not found ${mod}`);
}
})
);
config.ignoreWarnings = [/Failed to parse source map/];
return config;
};