[React Fundamentals] Development environment Setup

Source: Internet
Author: User

In this lesson we'll setup a simple build process for converting our ES6 React components into ES5 using Babel and Webpack

Install:

NPM I--save react react-dom
NPM i-d babel-loader babel-core babel-preset-es2015 babel-preset-react
NPM i-g Babel Webpack webpack-dev-server

Create files:

Touch App.js main.js Webpack.config.js

Webpack.config.js:

Module.exports ={entry:'./main.js', Output: {path:'./', FileName:"Index.js"}, Devserver: {inline:true, Port:3336}, module: {loaders: [{test:/\.jsx?$/, exclude:/(node_modules|bower_components)/, Loader:'Babel', query: {presets: ['es2015','react']                }            }        ]    }};

Index.html

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Setup</title></Head><Body><DivID= "App"></Div><Scriptsrc= "Index.js"></Script></Body></HTML>

App.js:

Import React from ' React 'default  class App extends React.component {    render () {         return  (            <span>hello react</span>        )    }}

Main.js:

Import React from ' React 'react-dom'./app '; Reactdom.render (<app/>, document.getElementById (' App '));

Run:

Webpack-dev-server

[React Fundamentals] Development environment Setup

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.