oliviertassinari / babel-plugin-transform-react-remove-prop-types

Remove unnecessary React propTypes from the production build. :balloon:
MIT License
897 stars 61 forks source link

How to use it with multiple environments in babel-env? #198

Open ghost opened 3 years ago

ghost commented 3 years ago

My .babelrc has 2 environments that are used for differential serving:

"env": {
  "modern": {
    "presets": [
      [
        "@babel/preset-env",
        {
          "targets": {
            "esmodules": true
          }
        }
      ],
      "@babel/preset-react",
      "@babel/preset-flow"
    ],
    "plugins": [...],
  },
  "legacy": {
    "presets": [
      [
        "@babel/preset-env",
        {
          "targets": {
            "esmodules": false
          }
        }
      ],
      "@babel/preset-react",
      "@babel/preset-flow"
    ],
    "plugins": [...],
  }
}

These can be selected using the BABEL_ENV flag. Since either modern or legacy is selected I can't just add another environment (production) because two environments cannot be selected at the same time.