通过Webpack 5应用程序构建后,在Internet Explorer(IE11)上停止工作 [英] After build via Webpack 5 app stoped working on Internet Explorer (IE11)

查看:857
本文介绍了通过Webpack 5应用程序构建后,在Internet Explorer(IE11)上停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

webpack.config.js中进行了一些细微调整之后,如Webpacks 5.0版本中所宣布的那样,博客文章的构建在大多数浏览器中仍然有效.

但是它停止在Internet Explorer(11)中工作,因为生成的输出混合了ES6ES5,因此与IE不兼容(参见图片).

由于使用各种babel插件实际上无法成功构建,所以我问自己是否存在简单"的解决方案.将ES5指定为生成的输出的方法.

webpack-5的beta阶段开始,我在

来自Medium which seems not working anymore.

module.exports = {
  output: {
    filename: [name].js,
    ecmaVersion: 5 // <- this flag
  }
}

Is there some "webpack built in way" in version 5.x to have ES5 as output target?

解决方案

From the webpack guide To v5 from v4, it says:

By default, webpack's runtime code uses ES2015 syntax to build smaller bundles. If your build targets environments that don't support this syntax (like IE11), you'll need to set target: ['web', 'es5'] to revert to ES5 syntax ('web' if target environment is browser).

So you can try to set:

target: ['web', 'es5']

then it will convert code to ES5.

这篇关于通过Webpack 5应用程序构建后,在Internet Explorer(IE11)上停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆