-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-overrides.js
59 lines (51 loc) · 1.65 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
const path = require('path')
const webpack = require('webpack')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
module.exports = function override(config, env) {
const fallback = config.resolve.fallback || {}
Object.assign(fallback, {
url: require.resolve('url'),
util: require.resolve('util'),
assert: require.resolve('assert'),
buffer: require.resolve('buffer'),
vm: require.resolve('vm-browserify'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
process: require.resolve('process/browser'),
os: require.resolve('os-browserify/browser'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
})
config.resolve.fallback = fallback
config.resolve.alias = {
...config.resolve.alias,
'bn.js': path.resolve(__dirname, 'node_modules/bn.js'),
'magic-sdk': path.resolve(__dirname, 'node_modules/magic-sdk/dist/cjs/index.js'),
}
config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
new webpack.IgnorePlugin({
resourceRegExp: /genesisStates\/[a-z]*\.json$/,
contextRegExp: /@ethereumjs\/common/,
}),
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
}),
])
config.ignoreWarnings = [/Failed to parse source map/]
config.module.rules.push({
test: /\.(js|mjs|jsx)$/,
enforce: 'pre',
loader: require.resolve('source-map-loader'),
resolve: {
fullySpecified: false,
},
})
if (env === 'production') {
config.devtool = false
}
return config
}