-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
22 lines (19 loc) · 843 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const ReactRefreshBabelPlugin = require('react-refresh/babel');
module.exports = {
overrideCracoConfig: ({ cracoConfig, context: { env } }) => {
const isDevelopment = env === 'development';
if (isDevelopment) {
if (!cracoConfig.babel) cracoConfig.babel = {};
if (!cracoConfig.babel.plugins) cracoConfig.babel.plugins = [];
if (!cracoConfig.webpack) cracoConfig.webpack = {};
if (!cracoConfig.webpack.plugins) cracoConfig.webpack.plugins = [];
// Configure Babel plugin
cracoConfig.babel.plugins.push(ReactRefreshBabelPlugin);
// Configure Webpack plugin
cracoConfig.webpack.plugins.push(new ReactRefreshWebpackPlugin());
}
// Always return the config object.
return cracoConfig;
},
};