-
-
Notifications
You must be signed in to change notification settings - Fork 27k
babel-preset-react-app doesn't support overriding targets #5216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Similar: #2592 |
I have a similar issue. I am trying to overwrite the My config:
|
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Will this be implemented? |
I have published a fork for my own purposes: https://www.npmjs.com/package/@zumper/babel-preset-react-app I went the route of adding a special “node” file that works like the existing “dependency” file. You would replace a line like this: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/webpack.config.js#L357 presets: [require.resolve('@zumper/babel-preset-react-app/node')], This will Babel-transform your files for use in a node environment. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
@ivosabev is seems this was implemented for this comment #892 (comment) references browserlist for these entries
But in create-react-app/packages/babel-preset-react-app/create.js Lines 82 to 89 in caf0a30
and browserlist override don't works it was added back here #5033 c9e1876#diff-7482288d6d13860f434d0b8171f20431 with this comment
cc @Timer please, can you elaborate on this? I just wanted to exclude polyfills and ES5 in bundle, and this is impossible now 😢 |
For anyone who still experiences issues, as a temporary workaround, you can override targets with following: babel/index.js // overrides babel-create-react-app preset to deliver es6 code
// at the moment of writing babel-create-react-app preset didn't allow to override targets and used ie9 as a default
const babelReactApp = require('babel-preset-react-app'); // eslint-disable-line
module.exports = (api, opts) => {
const env = process.env.BABEL_ENV || process.env.NODE_ENV;
const isEnvDevelopment = env === 'development';
const isEnvProduction = env === 'production';
const config = babelReactApp(api, opts);
// mutate babel-env-preset config for production and development
if (isEnvProduction || isEnvDevelopment) {
const envPresetConfig = config.presets.filter(preset => preset && preset[1] && preset[1].targets)[0][1];
if (envPresetConfig) {
envPresetConfig.useBuiltIns = false;
envPresetConfig.ignoreBrowserslistConfig = false;
// get from browserlistrc
envPresetConfig.targets = null;
}
}
return config;
}; and in bablerc {
// ...
"presets": [
"./babel"
],
//...
} Hovewer, still waiting for support from babel-create-react-app-preset to override such things. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
Sorry for offtop. Message to prevent issue from closing |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue. |
I'm working on making
react-scripts
support SSR for my project. I can handle most of what I need by editingreact-scripts
itself but my server-side build is still usingie: 9
as the target becausebabel-preset-react-app
doesn't allow for overriding the targets.There was a recent discussion about ignoring the"browserslist" settings, but this is a different ask. I would like to have a way to specify a dev or prod build for my app for either node or browser.
Ideally I would be able to specify the targets as an option to
babel-preset-react-app
. This allows me to copywebpack.config.dev.js
towebpack.config.dev-ser ver.js
and make the small handful of changes necessary to target node.(compare to
webpack.config.dev.js
)The text was updated successfully, but these errors were encountered: