2022-01-07 04:05:25 +00:00
|
|
|
const webpack = require('webpack');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
dev: (config) => {
|
|
|
|
// Override webpack 5 config from react-scripts to load polyfills
|
|
|
|
if (!config.resolve) config.resolve = {};
|
|
|
|
if (!config.resolve.fallback) config.resolve.fallback = {};
|
|
|
|
Object.assign(config.resolve.fallback, {
|
2022-01-07 04:18:37 +00:00
|
|
|
buffer: require.resolve('buffer'),
|
|
|
|
crypto: require.resolve('crypto-browserify'),
|
|
|
|
stream: require.resolve('stream-browserify'),
|
|
|
|
});
|
2022-01-07 04:05:25 +00:00
|
|
|
|
2022-01-07 04:18:37 +00:00
|
|
|
if (!config.plugins) config.plugins = [];
|
2022-01-07 04:05:25 +00:00
|
|
|
config.plugins.push(
|
|
|
|
new webpack.DefinePlugin({
|
2022-01-07 04:18:37 +00:00
|
|
|
'process.env.ENV': JSON.stringify('dev'),
|
2022-01-07 04:05:25 +00:00
|
|
|
})
|
2022-01-07 04:18:37 +00:00
|
|
|
);
|
2022-01-07 04:05:25 +00:00
|
|
|
config.plugins.push(
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
process: 'process/browser.js',
|
|
|
|
Buffer: ['buffer', 'Buffer'],
|
2022-01-07 04:18:37 +00:00
|
|
|
})
|
|
|
|
);
|
2022-01-07 04:05:25 +00:00
|
|
|
|
2022-01-07 04:18:37 +00:00
|
|
|
if (!config.ignoreWarnings) config.ignoreWarnings = [];
|
|
|
|
config.ignoreWarnings.push(/Failed to parse source map/);
|
2022-01-07 04:17:31 +00:00
|
|
|
|
2022-01-07 04:05:25 +00:00
|
|
|
return config;
|
|
|
|
},
|
|
|
|
prod: (config) => {
|
|
|
|
// Override webpack 5 config from react-scripts to load polyfills
|
|
|
|
if (!config.resolve) config.resolve = {};
|
|
|
|
if (!config.resolve.fallback) config.resolve.fallback = {};
|
|
|
|
Object.assign(config.resolve.fallback, {
|
2022-01-07 04:18:37 +00:00
|
|
|
buffer: require.resolve('buffer'),
|
|
|
|
crypto: require.resolve('crypto-browserify'),
|
|
|
|
stream: require.resolve('stream-browserify'),
|
|
|
|
});
|
2022-01-07 04:05:25 +00:00
|
|
|
|
2022-01-07 04:18:37 +00:00
|
|
|
if (!config.plugins) config.plugins = [];
|
2022-01-07 04:05:25 +00:00
|
|
|
config.plugins.push(
|
|
|
|
new webpack.DefinePlugin({
|
2022-01-07 04:18:37 +00:00
|
|
|
'process.env.ENV': JSON.stringify('prod'),
|
2022-01-07 04:05:25 +00:00
|
|
|
})
|
2022-01-07 04:18:37 +00:00
|
|
|
);
|
2022-01-07 04:05:25 +00:00
|
|
|
config.plugins.push(
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
process: 'process/browser.js',
|
|
|
|
Buffer: ['buffer', 'Buffer'],
|
2022-01-07 04:18:37 +00:00
|
|
|
})
|
|
|
|
);
|
2022-01-07 04:05:25 +00:00
|
|
|
|
2022-01-07 04:18:37 +00:00
|
|
|
if (!config.ignoreWarnings) config.ignoreWarnings = [];
|
|
|
|
config.ignoreWarnings.push(/Failed to parse source map/);
|
2022-01-07 04:17:31 +00:00
|
|
|
|
2022-01-07 04:05:25 +00:00
|
|
|
return config;
|
2022-01-07 04:18:37 +00:00
|
|
|
},
|
2022-01-07 04:05:25 +00:00
|
|
|
};
|