-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcraco.config.js
49 lines (44 loc) · 1.34 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
48
49
module.exports = {
babel: {
loaderOptions: babelLoaderOptions => {
const origBabelPresetCRAIndex = babelLoaderOptions.presets.findIndex(
preset => {
return preset[0].includes('babel-preset-react-app');
}
);
const origBabelPresetCRA =
babelLoaderOptions.presets[origBabelPresetCRAIndex];
babelLoaderOptions.presets[
origBabelPresetCRAIndex
] = function overridenPresetCRA(api, opts, env) {
const babelPresetCRAResult = require(origBabelPresetCRA[0])(
api,
origBabelPresetCRA[1],
env
);
babelPresetCRAResult.presets.forEach(preset => {
// detect @babel/preset-react with {development: true, runtime: 'automatic'}
const isReactPreset =
preset &&
preset[1] &&
preset[1].runtime === 'automatic' &&
preset[1].development === true;
if (isReactPreset) {
preset[1].importSource = '@welldone-software/why-did-you-render';
}
});
return babelPresetCRAResult;
};
return babelLoaderOptions;
},
},
// if you want to track react-redux selectors
webpack: {
alias: {
'react-redux':
process.env.NODE_ENV === 'development'
? 'react-redux/lib'
: 'react-redux',
},
},
};