question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

babel-preset-react-app doesn't support overriding targets

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
heygradycommented, Jan 4, 2019

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.

0reactions
stale[bot]commented, Apr 18, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found