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?
    1. module.exports = function (api) {
    2. api.cache(true);
    3. const presets = [ ... ];
    4. return {
    5. presets,
    6. plugins
    7. };
    8. }

    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:

    1. {
    2. "name": "my-package",
    3. "version": "1.0.0",
    4. "babel": {
    5. }
    6. }

    You are allowed to access any Node.js APIs, for example a dynamic configuration based on the process environment:

    1. const presets = [ ... ];
    2. const plugins = [ ... ];
    3. if (process.env["ENV"] === "prod") {
    4. plugins.push(...);
    5. }
    6. 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.

    1. require("@babel/core").transform("code", {
    2. plugins: ["@babel/plugin-transform-arrow-functions"]

    Check out the to see more configuration options.