egoist / poi

⚡A zero-config bundler for JavaScript applications.
https://poi.js.org
MIT License
5.22k stars 255 forks source link

Document how to override the target of the babel preset #681

Closed AlexGustafsson closed 4 years ago

AlexGustafsson commented 4 years ago

In the transforms guide there is mentioning of configuration of the poi/babel preset by specifying the options jsx, flow and typescript. The code, however, supports overriding of the env parameter in order to effectively control the target.

For example, I'm using the following babel.config.js file in order to use a more up-to-date target over the default IE 9:

const env = process.env.BABEL_ENV || process.env.NODE_ENV;
const isTest = env === 'test';
const browserlist = require('./package.json').browserslist;

const targets = isTest ? {node: 'current'} : browserlist;

module.exports = {
  presets: [
    ['poi/babel', {
      env: {targets}
    }]
  ]
}
egoist commented 4 years ago

Updated. https://poi.js.org/guide/transforms.html#options-env