babel-preset-react-app doesn't support overriding targets
See original GitHub issueI’m working on making react-scripts
support SSR for my project. I can handle most of what I need by editing react-scripts
itself but my server-side build is still using ie: 9
as the target because babel-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 copy webpack.config.dev.js
to webpack.config.dev-ser ver.js
and make the small handful of changes necessary to target node.
(compare to webpack.config.dev.js
)
presets: [
[
require.resolve('babel-preset-react-app/dependencies'),
{
helpers: true,
// wouldn't it be nice to specify target
targets: { node: 'current' }
},
],
],
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (2 by maintainers)
Top Results From Across the Web
How to overwrite babel's preset plugin options - Stack Overflow
It seems that Babel doesn't currently support these sorts of overrides (see https://github.com/babel/babel/issues/8799).
Read more >babel/preset-react
When spreading props, use inline object with spread elements directly instead of Babel's extend helper or Object.assign . .babelrc.js. module.exports = { ...
Read more >Adding TypeScript Support to a Babel React App - Medium
In this post, I'm going to walk through all of the steps we used to upgrade three of our applications so that we...
Read more >Configuration - Quokka.js
The files that you import / require from your Quokka file will be compiled using .babelrc file (or "babel": {...} section in your...
Read more >Create React App: A quick setup guide - LogRocket Blog
Officially, you cannot override this configuration. If you want to enforce a coding style, you can install and use Prettier (it's not integrated ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
This will Babel-transform your files for use in a node environment.
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.