我想支持一些较旧的Internet Explorer浏览器。通过降级某些模块并使用相关的polyfill设置我的webpack,我几乎可以完成这项工作。不幸的是其中一个模块@storybook/react
被捆绑在一起,并在IE中引起异常。
我曾尝试对文件进行分块并使用HtmlWebpackPlugin
进行注入,但是我想拥有另一个不包含@storybook/react
模块的IE捆绑包(幸运的是,该模块对于执行我的应用程序,因此我不需要在IE8上运行它)有可能吗?
这是我正在使用的配置的一部分
module.exports = {
context: path.resolve(__dirname, ".."),
entry: {
main: ["babel-polyfill", path.join(__dirname, "../src/index.js")],
vendor: [
"es5-shim",
"es5-shim/es5-sham",
"babel-polyfill",
"react",
"react-dom",
"react-redux",
"redux",
"redux-thunk"
]
},
output: {
path: assetsPath,
filename: "[name].js",
chunkFilename: "[name].js"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
enforce: "pre",
use: [
{
loader: "eslint-loader",
options: {
fix: true
}
}
],
exclude: [/node_modules/]
},
{
test: /\.js$/,
enforce: "post",
loader: "es3ify-loader",
exclude: [/node_modules/]
},
{
test: /\.(js|jsx)$/,
loader: "babel-loader",
exclude: [/node_modules/]
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
"file-loader",
{
loader: "img-loader",
options: {
enabled: true,
optipng: true
}
}
]
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: true,
screw_ie8: false
},
mangle: { screw_ie8: false },
output: { screw_ie8: false }
}),
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
minChunks: Infinity
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "../public/index.html"),
chunks: ["vendor", "main"],
filename: "index.html"
})
],
};