【发布时间】:2019-05-20 17:55:16
【问题描述】:
我正在编译我的应用程序并试图让它支持 IE。然而,polyfill 在我的供应商填充中留下了一个 const 语句,它破坏了 IE。
我的配置有问题吗?
网页包:
{
mode: "production",
entry: {
app: ["whatwg-fetch", "@babel/polyfill", "./src/app/app.js"]
},
output: {
path: path.resolve(
__dirname,
"temp/" + envData.environment + "/app/js"
),
filename: "[name].bundle.js",
publicPath: "/"
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: "initial"
}
}
}
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: "happypack/loader",
options: { babelrc: true, cacheDirectory: "./cache" }
}
]
}
}
Babelrc:
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"chrome": "55",
"ie": "8"
}
}
]
]
}
编辑:抱歉,我忘了包含我的快乐加载器配置,它确实通过 babel-loader 运行我的代码:
let plugins = [
new HardSourceWebpackPlugin(),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new HappyPack({
loaders: ["babel-loader"]
}),
new LiveReloadPlugin({
hostname: "localhost"
})
];
【问题讨论】:
-
尝试使用加载器:'babel-loader'。可能会对你有所帮助。
标签: javascript webpack babeljs polyfills babel-polyfill