1.安装babel-cli
npm install babel-cli --save
2.在package.json添加
"server": "set NODE_ENV=test&&nodemon --exec babel-node -- ./server/server.js"
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom",
"server": "set NODE_ENV=test&&nodemon --exec babel-node -- ./server/server.js",
"server_bak": "node server/server.js"
}
这样我们写的node后端就支持就支持es6啦!
3.在项目根目录下创建.babelrc文件
写入
"babel": {
"presets": [
"react-app"
],
"plugins": [
"transform-decorators-legacy",
[
"import",
{
"libraryName": "antd-mobile",
"style": "css"
}
]
]
}
这样我们写的node后端就支持就支持jsx环境啦!
网友评论