ncaught ReferenceError: $RefreshReg$ is not defined code example
Example: $RefreshReg$ is not defined
hey this worked for me to handle this issue, follow this step by step
1.install cross-env
2.add cross-env NODE_ENV=production and cross-env NODE_ENV=development
3. follow this config
```
const isDevPlugin = ['react-refresh/babel']
const isProdPlugin = [
'@babel/plugin-transform-block-scoping',
'transform-remove-console',
'babel-plugin-transform-remove-undefined',
['transform-react-remove-prop-types', { mode: 'wrap', ignoreFilenames: ['node_modules'] }]
]
const isProdDevPlugin = [
'@babel/plugin-transform-async-to-generator',
'@babel/plugin-syntax-dynamic-import',
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-transform-runtime', { corejs: 3, useESModules: true }],
['styled-jsx/babel', { optimizeForSpeed: true }]
]
const isPlugins = process.env.NODE_ENV !== 'production' ? isDevPlugin : isProdPlugin
{
test: /\.(js|jsx)$/,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: 3,
loose: true,
bugfixes: true,
modules: false
}
],
['@babel/preset-react', { useBuiltIns: true }]
],
plugins: [...isProdDevPlugin, ...isPlugins]
}
}
],
include: resolve(process.cwd(), 'src'),
exclude: /node_modules/
}
```
4. enjoy working