package.json
{ "name": "reactstart", "version": "1.0.0", "description": "react start", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "mhyang", "license": "ISC", "dependencies": { "babel": "^6.23.0", "babel-core": "^6.24.1", "babel-loader": "^7.0.0", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "babelify": "^7.3.0", "react": "^15.5.4", "react-dom": "^15.5.4", "webpack": "^2.4.1", "webpack-dev-server": "^2.4.5" } }
webpack.config.js
var webpack = require("webpack"); var path = require("path"); module.exports = { context: __dirname + "/src", entry: "./js/index.js", devServer: { port: 3333 }, module: { loaders: [{ test : /\.js?$/, exclude : /(node_modules)/, loader : "babel-loader", query : { presets : ["react", "es2015"] } }] }, output : { path : __dirname + "/src/", filename : "bundle.js" } };
webpack-dev-server --inline --hot
但是没有办法在localhost:3333下直接刷新 如果输入webpack-dev-server 在iframe模式下可以刷新