我正在尝试将es6转换到es5,但它不起作用。
我的Gruntfile.js
module.exports = function(grunt){
"use strict";
grunt.loadNpmTasks('grunt-babel');
grunt.initConfig({
"babel": {
options: {
sourceMap: true
},
dist: {
files: {
"dist/app.js": "app.js"
}
}
}
});
grunt.registerTask("default", ["babel"]);
}当我运行grunt时,文件dist/app.js在app.js上是相同的
出什么事了吗?
发布于 2015-11-16 17:03:17
我发现了错误。
我不得不预置一下2015年:npm install -D babel-preset-es2015
并在package.json中配置babel。
{
"name": "babel",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"babel": {
"presets": [
"es2015"
]
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.1.18",
"babel-preset-es2015": "^6.1.18",
"babelify": "^7.2.0",
"grunt": "^0.4.5",
"grunt-babel": "^6.0.0",
"grunt-browserify": "^4.0.1",
"grunt-contrib-watch": "^0.6.1",
"load-grunt-tasks": "^3.3.0"
}
}发布于 2016-07-26 11:48:17
您必须创建一个文件名.babelrc,并且您必须在该文件中写入以下内容:
{
'presets':['es2015']
}https://stackoverflow.com/questions/33630369
复制相似问题