0

我试图让我的资产捆绑与 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
4

1 回答 1

0

我自己解决了。问题是我有多个 node_modules 文件夹,而 gulp 使用了带有错误 babel 版本的文件夹。

于 2019-01-13T09:30:28.620 回答