我打算使用gulp使用babel,我添加了gulp-babel和babel核心并预设了环境。
当我运行babel任务"gulp js"
时,某些es2015 +代码(例如访存api和promise)不会转换为es5代码。我是否缺少预设/浏览器列表中的任何配置?
在此先感谢您的帮助。我的目标是从IE11和其他浏览器的最新2版本
我已在github https://github.com/shmdhussain/gulp-babel-demo
中添加了演示我的gulpfile是
var gulp = require('gulp');
var babel = require('gulp-babel');
// Development Tasks
// -----------------
//babel tasks
gulp.task('js', function(){
return gulp.src(['app/preCompileJs/**/*.js'])
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(gulp.dest('app/js'));
});
打包json
{
"name": "project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gulp": "gulp"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"gulp": "^3.9.0",
"gulp-babel": "^8.0.0"
}
}
.browserlistrc
last 2 version
> 1%
ie 11
.babelrc
{
"presets": ['@babel/env']
}