Multiple envs: 1 for node, 1 for browsers #189
Comments
We're doing something similar where our e2e tests also use Babel. Our config looks like this (stripped down for brevity) {
"presets": [
"react",
["env", {
"targets": {
"electron": "current"
},
"modules": false,
}]
],
"env": {
"test-e2e": {
"presets": [
"react",
["env", {
"targets": {
"node": "current"
},
}]
],
},
}
} We use |
@mozmorris Nice solution! Also, options specific to a certain environment are merged into and overwrite non-env specific options, so you can set |
If you have a bunch of options or conditionals, another option (which I'm currently using) is to build a preset ala https://github.com/facebookincubator/create-react-app/blob/master/packages/babel-preset-react-app/index.js Similarly, once |
Closing for now, as there's nothing really actionable from this side. @verekia let us know if you run into any additional issues (and fair warning, there be some dragons with using the env option :D) |
Let's say we are using Babel on both the back-end with Node and on the front-end with Webpack. What would be the correct way to setup
babel-preset-env
so that it performs minimal transformations for Node, but more transformations for browsers when building with Webpack?From my understanding, Babel considers the lowest common denominator, even between different beasts like Node and browsers. Therefore, the following does not work from the tests I've run:
What would be your recommendation in such situation? Using 2 different
.babelrc
files?Is it something you plan to address in the future?
Thanks
The text was updated successfully, but these errors were encountered: