"babel-cli": "^6.26.0", "babel-core": "^6.26.3", "babel-preset-es2015": "^6.24.1", "gulp-babel": "6",
如上代码所示,安装以上版本的babel插件,bable更新很快,当版本不一致会冲突,导致出现 Plugin/Preset files are not allowed to export objects, only functions 。
gulp压缩js代码如下
const uglify = require('gulp-uglify'); //js压缩 const babel = require("gulp-babel"); // gulp打包manager\page\dist\js gulp.task('revJs', ()=> { return gulp.src([filePath + '/page/dist/js/*.js']) .pipe(babel({//编译ES6 presets: ['es2015'] })) .pipe(uglify())//压缩js .pipe(gulp.dest( 'dist/manager/page/dist/js')) })