我正在尝试将 ES6 代码转换为简单的 JS,在 gulp 中使用 babel。运行下面的代码我得到 [Error in Plugin "gulp-babel"] 消息:[Plugin/Preset files are not allowed to export objects, only functions.]
var gulp = require('gulp');
var babel = require('gulp-babel');
gulp.task('scripts',function(){
return gulp.src(['src/scripts/app.js'])
.pipe(babel({presets:['es2015']}))
.pipe(gulp.dest('build/scripts/'))
});
src/scripts/app.js
const hello = (name) => {
return `hello ${name}`;
};
指导我将 ES6 代码转换为 vanilla JS 将不胜感激。