-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfig-overrides.js
53 lines (48 loc) · 1.84 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
// @ts-ignore
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = (config, env) => {
// Resto de tu configuración...
// Verifica si resolve.fallback ya está definido
if (!config.resolve.fallback) {
config.resolve.fallback = {
process: require.resolve('process/browser'),
stream: require.resolve('stream-browserify'),
fs: require.resolve('browserify-fs'),
path: require.resolve('path-browserify'),
assert: require.resolve('assert'),
http: require.resolve('http-browserify'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify'),
zlib: require.resolve('browserify-zlib'),
};
} else {
config.resolve.fallback.process = require.resolve('process');
config.resolve.fallback.stream = require.resolve('stream-browserify');
config.resolve.fallback.fs = require.resolve('browserify-fs');
config.resolve.fallback.path = require.resolve('path-browserify');
config.resolve.fallback.assert = require.resolve('assert');
config.resolve.fallback.http = require.resolve('http-browserify');
config.resolve.fallback.https = require.resolve('https-browserify');
config.resolve.fallback.os = require.resolve('os-browserify');
config.resolve.fallback.zlib = require.resolve('browserify-zlib');
}
config.resolve.fallback.Buffer = require.resolve('buffer');
// Agrega el plugin ProvidePlugin para process
config.plugins.push(
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process',
})
);
if (process.env.REACT_APP_ENV === 'dev') {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
statsOptions: {
source: false
}
}))
}
return config;
};