forked from saasify-sh/saasify-frontend-boilerplate-cra
-
Notifications
You must be signed in to change notification settings - Fork 5
/
config-overrides.js
57 lines (53 loc) · 1.88 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
54
55
56
57
const DirectoryNamedWebpackPlugin = require('directory-named-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const path = require('path')
const {
override,
addDecoratorsLegacy,
addBundleVisualizer,
addBabelPlugin,
addWebpackAlias,
addWebpackPlugin,
disableEsLint
} = require('customize-cra')
module.exports = override(
addDecoratorsLegacy(),
disableEsLint(),
// eslint-disable-next-line
process.env.BUNDLE_VISUALIZE == 1 && addBundleVisualizer(),
addBabelPlugin([
'@babel/plugin-proposal-class-properties',
{
loose: true
}
]),
addBabelPlugin('@babel/plugin-proposal-optional-chaining'),
addWebpackAlias({
'@ant-design/icons/lib/dist$': path.join(__dirname, 'src/lib/icons.js'),
// TODO: It's unclear why this is necessary when locally linking react-saasify, but
// without it we get random client-side react errors...
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom'),
mobx: path.resolve('./node_modules/mobx'),
'mobx-react': path.resolve('./node_modules/mobx-react'),
'react-router-dom': path.resolve('./node_modules/react-router-dom')
}),
addWebpackPlugin(new CompressionPlugin()),
(config) => {
// allow relative imports from the top-level src directory
config.resolve.modules = [path.join(__dirname, 'src')].concat(
config.resolve.modules
)
// allow custom resolving of default directory imports by attempting to load
// 'DirName/DirName.js' if `DirName/index.js` doesn't exist which negates
// having a useless index.js file for every component and route.
config.resolve.plugins = [
new DirectoryNamedWebpackPlugin({
exclude: /node_modules/,
honorIndex: true,
honorPackage: ['browser', 'module', 'main']
})
].concat(config.resolve.plugins || [])
return config
}
)