我试图让我的资产捆绑与 es6 一起工作,但它不会工作。我的 package.json 是:
"devDependencies": {
"babel-preset-es2015": "^6.6.0",
"del": "^2.2.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2"
}
我的 bundle.config.json 包含:
options: {
uglify: ['production'], // uglify the resulting bundle in prod
rev: ['production'], // rev the resulting bundle in prod
transforms: {
scripts: lazypipe().pipe(babel, {
presets: ['es2015']
}
)
}
}
我的捆绑任务是:
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var bundle = require('gulp-bundle-assets');
var del = require('del');
[...]
gulp.task('bundle', function() {
del([
'./atlas3src/public/assets/bundles/**/*',
]);
return gulp.src('./bundle.config.js')
.pipe(bundle())
.pipe(bundle.results({
dest: './atlas3src/public/assets/',
pathPrefix: '/assets/bundles/'
}))
.pipe(gulp.dest('./atlas3src/public/assets/bundles/'));
});
当我尝试捆绑时,它会引发以下错误:
[20:30:33] Error in plugin "gulp-babel"
Message:
Plugin/Preset files are not allowed to export objects, only functions. In /home/ubuntu/workspace/node_modules/babel-preset-es2015/lib/index.js