Configure Babel
All Babel API options are allowed. However, if the option requires JavaScript, you may want to use a JavaScript .
- You are using a monorepo?
- You want to compile
node_modules
?
- You have a configuration that only applies to a single part of your project?
- Guy Fieri is your hero?
module.exports = function (api) {
api.cache(true);
const presets = [ ... ];
return {
presets,
plugins
};
}
Check out the babel.config.json
documentation to see more configuration options.
Create a file called .babelrc.json
with the following content in your project.
Check out the to see more configuration options.
Alternatively, you can choose to specify your .babelrc.json
config from within package.json
using the babel
key like so:
{
"name": "my-package",
"version": "1.0.0",
"babel": {
}
}
You are allowed to access any Node.js APIs, for example a dynamic configuration based on the process environment:
const presets = [ ... ];
const plugins = [ ... ];
if (process.env["ENV"] === "prod") {
plugins.push(...);
}
module.exports = { presets, plugins };
You can read more about JavaScript configuration files in the
Check out the babel-cli documentation to see more configuration options.
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-transform-arrow-functions"]
Check out the to see more configuration options.