0

我需要让 Chrome 41 和 IE11 可以访问我们的网站。然而,缩小引入了一些 unicode 字符,这些字符在较新的浏览器中完全没有问题,但在前面提到的浏览器中会导致“非法令牌”和“预期的十六进制数字”错误。

从缩小的捆绑包中查看这个缩短的代码:

return e.export = { Afr:"\u{1d504}" }

这对应于Unicode Character 'MATHEMATICAL FRAKTUR CAPITAL A' (U+1D504)也称为 。然而,它在 Chrome 41(GoogleBot 中使用的那个)和 IE11(从未下载过 Chrome 或 Firefox 的 Windows 8.x 用户)中被视为非法令牌。

是否有任何 webpack 插件或转换工具可以对这些值进行不同的编码?

我们目前使用UglifyJS插件进行缩小。

4

1 回答 1

0

实际上,我并没有解决这个问题,但我意识到该版本"uglifyjs-webpack-plugin": "1.3.0",设置为对这些字符进行编码(很可能来自react-html-parser)。

查看我已删除的配置以使其适用于浏览器。

new UglifyJsPlugin({
    uglifyOptions: {
      output: {
          // This was turned in the app because "emoji and regex" values 
          // were not minified properly, citing this issue:
          // https://github.com/facebook/create-react-app/issues/2488
          // However, the issue was solved a long time ago and this just broke
          // the site for IE11 and Chrome 41/GoogleBot
          ascii_only: true,
        },
      },
    }),
于 2019-02-25T17:18:53.007 回答