【发布时间】:2019-07-28 05:53:39
【问题描述】:
我正在从 Webpack 3 升级到 Webpack 4。 在 index.html 我有以下内容:
<link rel="manifest" href="<%= require('!file-loader?name=[path][name]-[hash:6].[ext]!static/manifest') %>">
但是升级后它就停止工作了。编译失败说:
模块解析失败:在 'module.exports = __w...' 附近进行解析时,JSON 中位置 0 处的意外标记 m
似乎 Webpack 正在尝试解析 json 文件(可能两次),这不是我需要的(文档提到现在默认解析 json 文件)。 不确定 'require' + file-loader 中的这种行为变化是设计使然还是错误。尝试使用 !!file-loader 会产生相同的结果。
另一种选择是使用带有 [hash] 的 copy-webpack-plugin,但是如何链接到 index.html 中的新名称?
【问题讨论】:
标签: json webpack hash webpack-4 webpack-file-loader