【发布时间】:2021-08-25 17:28:01
【问题描述】:
我试图弄清楚如何放弃浏览器支持。例如 IE11,如何使用 webpack 执行此操作并防止它捆绑代码,因为它无论如何都会中断。并显示该浏览器的 UI(不支持浏览器...)。我遇到了浏览器列表,我知道它是用于浏览器选择的,但找不到使用它的解决方法。
假设我有一些实用功能 isIE11 可以检测浏览器,并且想做这样的事情:
{
entry: isIE11 ? 'index.ie11.js' : 'index.js',
output: {
path: __dirname + '/dist',
filename: 'index_bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
title: 'My App',
template: isIE11 ? 'src/ie11.index.html.hbs' : 'src/index.html.hbs'
filename: 'assets/index.html'
})
]
}
即使在 ie11 中显示这个简单的 UI 时不需要任何模块
【问题讨论】:
标签: javascript webpack bundle webpack-dev-server html-webpack-plugin