40.将babel配置项存在.babelrc文件中,在根目录中创建.babelrc文件,内容如下
{ "presets": ["react", "es2015"] }
41.修改webpack.config.js文件,修改内容如下
module.exports = { entry: __dirname + "/app/Greeter.js", output: { path: __dirname + "/public", filename: "bundle.js" }, devServer:{ contentBase:"./public", historyApiFallback:true, inline:true }, module:{ loaders:[ { test:/\.json$/, loader:"json-loader" }, { test:/\.js$/, exclude:/node_modules/, loader:'babel-loader' } ] } }
42.验证配置文件,修改config.json文件,修改内容如下
{ "greetText":"add .babelrc file " }
43.使用webpack命令进行打包
webpack
44.在浏览器中打开index.html文件查看结果,输出内容如下
本文转自 素颜猪 51CTO博客,原文链接:http://blog.51cto.com/suyanzhu/1899062