-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig-overrides.js
95 lines (80 loc) · 3.04 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// const webpack = require("webpack")
// module.exports = function override(config, env) {
// //do stuff with the webpack config...
// config.resolve.fallback = {
// ...config.resolve.fallback,
// stream: require.resolve("stream-browserify"),
// buffer: require.resolve("buffer"),
// }
// config.resolve.extensions = [...config.resolve.extensions, ".ts", ".js"]
// config.plugins = [
// ...config.plugins,
// new webpack.ProvidePlugin({
// process: "process/browser",
// Buffer: ["buffer", "Buffer"],
// }),
// ]
// return config
// }
// const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
// module.exports = function override(config, env) {
// config.resolve = {
// fallback: {
// stream: require.resolve('stream-browserify'),
// },
// // NOTE: I added this; missing in Substrate template and causes missing module errors;
// extensions: [...config.resolve.extensions, '.ts', '.js'],
// };
// config.plugins.push(new NodePolyfillPlugin());
// return config;
// };
// Leave commented out configs above for a certain period as an archive of what we tried earlier that didn't work in build mode;
// node-polyfill-webpack-plugin - this depency is installed because it contains process, buffer, util and other sub-dependencies, so we don't add them as deps separately;
// Works on MacOs:
const webpack = require('webpack');
// const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
module.exports = function override(config) {
config.resolve.fallback = {
...config.resolve.fallback,
process: require.resolve('process/browser'),
zlib: require.resolve('browserify-zlib'),
stream: require.resolve('stream-browserify'),
util: require.resolve('util'),
buffer: require.resolve('buffer'),
asset: require.resolve('assert'),
console: require.resolve('console-browserify'),
};
// Option 1 that works - use either one;
config.plugins.push(
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
})
);
// Option 2 that works - use either one;
// config.plugins.push(new NodePolyfillPlugin());
return config;
};
// Works on Windows:
// const webpack = require('webpack');
// const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
// module.exports = function override(config) {
// config.resolve.fallback = {
// process: require.resolve('process/browser'),
// zlib: require.resolve('browserify-zlib'),
// stream: require.resolve('stream-browserify'),
// util: require.resolve('util'),
// buffer: require.resolve('buffer'),
// asset: require.resolve('assert'),
// };
// // Option 1 that works - use either one;
// // config.plugins.push(
// // new webpack.ProvidePlugin({
// // process: 'process/browser.js',
// // Buffer: ['buffer', 'Buffer'],
// // })
// // );
// // Option 2 that works - use either one;
// config.plugins.push(new NodePolyfillPlugin());
// return config;
// };