我正在尝试使用gulp-babel,这样我就可以开始在我的 ES5 应用程序中编写一些 ES6 / ES2015 代码。
var gulp = require('gulp'),
gutil = require('gulp-util'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
sass = require('gulp-ruby-sass'),
streamqueue = require('streamqueue'),
sourcemaps = require('gulp-sourcemaps'),
templateCache = require('gulp-angular-templatecache'),
htmlReplace = require('gulp-html-replace'),
runSequence = require('run-sequence'),
stripDebug = require('gulp-strip-debug'),
del = require('del'),
es = require('event-stream'),
webpack = require('webpack-stream'),
babel = require('gulp-babel'),
browserSync = require('browser-sync').create();
在我的代码中,问题出在下面:
gulp.task('build-min-bundle', function() {
gutil.log(gutil.colors.blue.bold(' Compiled bundle file contains these modules:'));
for (var i=0; i<paths.scripts.length; i++) {
gutil.log(gutil.colors.yellow.bold(' '+paths.scripts[i]));
}
return gulp.src(paths.bundle)
.pipe(stripDebug())
.pipe(concat(dist))
.pipe(babel()) // <--
.pipe(uglify())
.on('error', errorlog)
.pipe(gulp.dest('app/assets/js'));
});
我最初尝试过这个:
.pipe(babel({
presets: ['es2015']
}))
严格模式下的参数名称冲突 (2774:5)