-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcraco.config.js
47 lines (41 loc) · 1.22 KB
/
craco.config.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
const webpack = require('webpack');
function configureWebpack(webpackConfig, { env, paths }) {
// fallbacks
const fallback = webpackConfig.resolve.fallback || {};
Object.assign(fallback, {
crypto: require.resolve('crypto-browserify'),
fs: require.resolve('browserify-fs'),
stream: require.resolve('stream-browserify'),
util: require.resolve('util'),
path: require.resolve('path-browserify'),
'process/browser': require.resolve('process/browser'),
vm: require.resolve('vm-browserify'),
});
webpackConfig.resolve.fallback = fallback;
webpackConfig.plugins = (webpackConfig.plugins || []).concat([
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
]);
webpackConfig.ignoreWarnings = [
/Failed to parse source map/,
function ignoreSourcemapsloaderWarnings(warning) {
return (
warning.module &&
warning.module.resource.includes('node_modules') &&
warning.details &&
warning.details.includes('source-map-loader')
);
},
];
return webpackConfig;
}
function configureCraco() {
return {
webpack: {
configure: configureWebpack,
},
};
}
module.exports = configureCraco();