按babel官方教程来配置的:
gulpfile.js
var gulp = require("gulp");var babel = require("gulp-babel");
gulp.task("default", function () { return gulp.src("src/app.js")
.pipe(babel())
.pipe(gulp.dest("dist"));
});
app.js
'use strict';let a = 'hello world';
还需要安装babel-preset-es2015插件,才能把es6编译成es5
npm install --save-dev babel-preset-es2015
在gulpfile.js中增加presets
var gulp = require("gulp");var babel = require("gulp-babel");
gulp.task("default", function () { return gulp.src("src/app.js")
.pipe(babel({ presets: ['es2015']
}))
.pipe(gulp.dest("dist"));
});
npm install --save-dev babel-preset-es2015
在gulpfile.js中增加presets
var gulp = require("gulp");
var babel = require("gulp-babel");
gulp.task("default", function () {
return gulp.src("src/app.js")
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest("dist"));
});