-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
50 lines (48 loc) · 1.41 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
const webpack = require('webpack');
module.exports = {
webpack: function(config, env) {
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
"stream": require.resolve("stream-browserify"),
"http": require.resolve("stream-http"),
"https": require.resolve("https-browserify"),
"url": require.resolve("url"),
"crypto": require.resolve("crypto-browserify"),
"zlib": require.resolve("browserify-zlib"),
"path": require.resolve("path-browserify"),
"fs": require.resolve("graceful-fs"),
"buffer": require.resolve("buffer"),
})
config.resolve.fallback = fallback;
config.plugins = (config.plugins || []).concat([
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 "stream":
resource.request = "readable-stream";
break;
default:
throw new Error(`Not found ${mod}`);
}
}),
]);
config.module.rules.push({
test: /\.m?js/,
resolve: {
fullySpecified: false,
fallback: {
"fs": false
},
}
})
config.ignoreWarnings = [/Failed to parse source map/];
return config;
},
}