注:配置webpack在第34篇
如何将将jsx文件转换为js文件,33篇有介绍如何babel转换
其实只要一个npm script 就可以了,webpack.config.js并不需要改动
"scripts": { "jsxTrans":"babel --presets react jsx --out-dir funcjs",//这里 "build": "npm run clean && npm run jsxTrans && webpack",//打包 "watch": "webpack --progress --watch", "clean": "rimraf dist/*", "server": "node server.js", "start": " npm run jsxTrans && webpack-dev-server --open" },