[Poi] Customize Babel to Build a React App with Poi

Developing React with Poi is as easy as adding the babel-preset-react-appto a .babelrc and installing React. This lesson will walk you through that quick process and get your React app up-and-running.

Install:

npm i react react-dom babel-preset-react-app babel-plugin-react-require

.babelrc:

{
    "presets": [
       "react-app"
    ],
    "plugins": [
       "react-require"
    ]
}

index.js:

// import React from 'react'; // NO NEED because babel-plugin-react-require

import {render} from 'react-dom';

render(<h1>React</h1>, document.getElementById("app"))

Run:

poi
原文地址:https://www.cnblogs.com/Answer1215/p/8181447.html