-
Notifications
You must be signed in to change notification settings - Fork 43
/
config-overrides.js
39 lines (33 loc) · 1.18 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
const overrideJsTsLoader = require('./react-app-rewire-js-ts');
const rewireCssModules = require('./react-app-rewire-css');
/* config-overrides.js */
module.exports = function override(config, env) {
// (config, env, babelPlugins = [])
config = overrideJsTsLoader(config, env);
// polyfills
config.entry = ['babel-polyfill', ...config.entry];
// css, sass, less
config = rewireCssModules(config, env);
// ForkTsCheckerWebpackPlugin overide
config.plugins.forEach((plugin, idx) => {
try {
const objectName = plugin.constructor.name;
if (objectName === 'ForkTsCheckerWebpackPlugin') {
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
config.plugins[idx] = new ForkTsCheckerWebpackPlugin({
...plugin.options,
workers: ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE,
memoryLimit: 2048,
tslint: false,
});
}
} catch (error) {}
});
// webpack-bundle-analyzer
if (process.env.WEBPACK_ANALYZER) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
config.plugins.push(new BundleAnalyzerPlugin());
}
return config;
};