- Why Vue"s Webpack template does not use polyfill can also use ES6+ methods such as Object.assign on IE browsers. And there is no babel-polyfill in the package.json and related configuration of the template
- can"t babel-loader automatically add relevant polyfill based on ES6 usage in my code? I feel that using my configuration is based on the polyfill added by browserlist
- when I use Webpack4 myself, I need to use the ES6+ method correctly on my IE browser. You need to add a line
import "babel-polyfill"
to the entry file.
attach my webpack configuration:
"use strict";
const path = require("path");
module.exports = {
mode: "development",
entry: {
index: path.join(__dirname, "./index.js"),
},
output: {
filename: "[name].bundle.js",
},
devtool: "cheap-module-eval-source-map",
devServer: {
contentBase: path.resolve(__dirname, "./"),
port: 8000,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
cacheDirectory: true,
presets: [[ "env", {
useBuiltIns: true,
}]],
plugins: [ "transform-runtime" ],
},
},
},
],
},
};