Webpack 5 需要 JSON 作为 `asset/resource` 而不是 `asset/source`

问题描述 投票:0回答:0

我正在尝试在我的 HTML (pug) 中加载一个 JSON 文件:

link(rel="manifest" href=require("/meta/webmanifest.json"))

但是 href 被替换为 JSON 的内容:

<link rel="manifest" href="{&quot;name&quot;:&quot;...}">

我的 webpack 配置中有

{test: /\.(ico|svg|png|ttf|json)$/, type:  "asset/resource"},
但这不会改变 JSON 的行为。有什么办法解决这个问题吗?

(使用带有 pug-plugin 的 pug)

webpack pug
© www.soinside.com 2019 - 2024. All rights reserved.