Skip to main content

@roots/bud-babel

Babel can be added by installing the @roots/bud-babel extension.

Installation​

npm install @roots/bud-babel --save-dev

Configuration​

@roots/bud-babel comes configured with:

Presets​

Presets are registered to bud.babel.presets.

console.dir(bud.babel.presets)

Add a preset​

It will be appended to whatever presets are already registered.

bud.babel.setPreset('@babel/preset-env')

Remove preset​

Use bud.babel.unsetPreset to remove a preset, if present.

bud.babel.unsetPreset('@babel/preset-env')

Fully override preset configuration​

Pass an array of presets to bud.babel.setPresets to fully replace the existing presents configuration.

bud.babel.setPresets(['@babel/preset-env'])

Set options on a preset​

bud.babel.setPresetOptions('@babel/preset-env', {
useBuiltIns: 'entry',
})

Plugins​

Managing plugins uses nearly the exact same API.

Add a plugin​

bud.babel.setPlugin('@babel/plugin-transform-runtime')

Add a plugin with options​

bud.babel.setPlugin(['@babel/plugin-transform-runtime', {helpers: false}])

Remove a plugin​

bud.babel.unsetPlugin('@babel/plugin-transform-runtime')

Override any plugin options​

bud.babel.setPluginOptions('@babel/plugin-transform-runtime', {
helpers: false,
})

Fully override plugins​

bud.babel.setPlugins(['@babel/plugin-transform-runtime'])