Configure Babel

To configure Babel to compile JSX and modern JavaScript code, create a babel.config.js file under the root of the project and put the following module.exports object in it:

babel.config.js

module.exports = {
  presets: ['@babel/preset-react', '@babel/preset-env'],
};

These presets were already installed above. The env preset is the one Babel uses to transform modern JavaScript (and it’s configurable if you need to target just modern browsers and make the bundle smaller). The react preset is for the mighty JSX extension.

Comments

Leave a Comment

All fields are required. Your email address will not be published.