Configure Babel

Outside of a browser, Babel only runs the transformations you explicitly indicate, so we need to supply a list of transformations for Babel to do anything. To speed up the configuration process, we’ll use the react-app preset, which combines the most useful options for React applications. This preset includes JSX support, as well as other options that support most common browsers and the testing environment we’ll use in Chapter 4, Test Your React Components. Install Babel, the Babel loader, and the react-app preset from npm:

 $ ​​npm​​ ​​i​​ ​​--save-dev​​ ​​babel-loader​​ ​​babel-core​​ ​​babel-preset-react-app

You’ll need to install the Babel core dependency explicitly because the Babel loader developers decided to let ...

Get React for Real now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.