-
Notifications
You must be signed in to change notification settings - Fork 5
/
config-overrides.js
32 lines (24 loc) · 1003 Bytes
/
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
const { override, disableEsLint, addBabelPlugins, addWebpackAlias } = require('customize-cra')
const LoadablePlugin = require('@loadable/webpack-plugin')
const { existsSync } = require('fs')
const { appRootPath, appConfigOverrides, appPackage } = require('./src/paths')
const { _moduleAliases } = require(appPackage)
const hasCustomConfigOverrides = existsSync(appConfigOverrides)
const aliases = {}
Object.keys(_moduleAliases).forEach(key => {
aliases[key] = _moduleAliases[key].replace('.', appRootPath)
})
const addLoadablePlugin = config => {
config.plugins.push(
new LoadablePlugin()
)
config.plugins[0].options.inject = false
return config
}
module.exports = override(
process.env.NODE_ENV === 'production' && addLoadablePlugin,
disableEsLint(),
...addBabelPlugins('transform-imports', '@loadable/babel-plugin', 'transform-react-remove-prop-types'),
addWebpackAlias({ ...aliases, 'lodash-es': 'lodash' }),
hasCustomConfigOverrides && require(appConfigOverrides)
)