我想使用babelJs将es6(或es7)的javascript源转换为es5。所以我创建了一个项目。这是我的package.json文件:
{
"name": "myapp",
"version": "1.0.0",
"description": "my front end app",
"main": "gulpfile.js",
"directories": {
"test": "test"
},
"dependencies": {},
"devDependencies": {
"babel-cli": "^6.10.1"
},
"scripts": {
"build-js": "babel app/src/js -d app/libs/",
},
"author": "",
"license": "ISC"
}
我创建了一个javascript文件:
var sayHello = name => {
return "Hello: " + name;
};
var result = sayHello("Sandeep"),
message = document.createElement("H1");
message.innerText = result;
document.body.appendChild(message);
当我运行我的任务build-js时,输出文件包含与输入文件相同的内容。翻译没有发生。还有什么可以做的吗? 感谢