安装依赖包 #

生产依赖

npm install react react-dom  -S

开发依赖

npm install babel-core babel-loader babel-preset-es2015 babel-preset-react babel-preset-react-hmre webpack webpack-dev-middleware webpack-hot-middleware -D

webpack配置 #

let path = require('path');
let webpack = require('webpack');
module.exports = {
  devtool: 'cheap-module-eval-source-map',
  entry: [
    "webpack-hot-middleware/client",
    "./index.js"
  ],
  output:{
    path:path.join(__dirname,'dist'),
    filename:'bundle.js',
    publicPath:'/static/'
  },
  plugins:[
    new webpack.optimize.OccurrenceOrderPlugin(),
    new webpack.HotModuleReplacementPlugin()
  ],
  module:{
    loaders:[
      {
        test:/\.js$/,
        loaders:["babel-loader"],
        exclude:/node_modules/,
        include:__dirname
      }
    ]
  }
}