module.exports = { // 将 ES6 代码转换为 ES5 transpileDependencies: ['flv.js', 'webpack-dev-server/client'], chainWebpack: function(config) { config.entry.app = ['@babel/polyfill', './src/main.js']; // 使用@babel/polyfill代替babel-polyfill config.module .rule('js') .use('babel-loader') .loader('babel-loader') .tap(function(options) { // 修改babel-loader选项 options.presets = ['@babel/preset-env']; return options; }); } };

Webpack 配置:使用 Babel 将 ES6 代码转换为 ES5

原文地址: https://www.cveoy.top/t/topic/otOG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录