我正在尝试转换ES6等浏览器支持的ES6代码。我正在通过webpack-stream插件将Webpack与Gulp配合使用:
/gulpfile.js
...
const webpack = require('webpack-stream');
gulp.task('js_webpack', ['jest'], function() {
return gulp.src('./src/js/**/*.js')
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('./dist/js'));
});
...
/webpack.config.js
const path = require('path');
module.exports = {
entry: {
"course-search": './src/js/course-search.bundle.js',
...
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist/js')
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}],
},
mode: 'development',
devtool: 'inline-source-map'
}
一切正常。一切都捆绑在一起并向下堆积。但是,not supported in IE的forEach位于生成的JS文件中。
因此,我正在尝试设置可接受的目标浏览器列表:
/。browserslistrc
> 1%
ie >= 11
ios 7
这不正确吗?为什么仍然在dist /文件中接受forEach?
如果有帮助,这也是我的babel配置文件:
/。babelrc
{
"presets": [
"@babel/preset-env"
]
}