Created by: heygrady
https://github.com/facebook/create-react-app/issues/5216
Adds a few new options for babel-preset-react-app
. This is useful for cases where you want to customize your build targets, like building for node. This is required for adding server-side rendering to a forked/ejected react-scripts project.
-
presetEnv
- defaults to undefined. Used to override the default values for development and prod. Can be any valid options for@babel/present-env
-
presetEnvTest
- defaults to undefined. Used to override the default values for test. Can be any valid options for@babel/present-env
-
regenerator
- defaults to true, set to false in cases where your targets all support generators natively (like for a node target)
Usage:
Compare to webpack.config.prod.js
application bundle
presets: [
[
require.resolve('babel-preset-react-app'),
{
presetEnv: {
modules: 'cjs',
targets: { node: 'current' },
},
regenerator: false,
},
],
],
Compare to webpack.config.prod.js
dependency bundle
presets: [
[
require.resolve('babel-preset-react-app/dependencies'),
{
helpers: true,
presetEnv: {
modules: 'cjs',
targets: { node: 'current' },
},
regenerator: false,
},
],
],