Skip to content

Commit

Permalink
fix(manifest): include assets referenced in html (#14657)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Oct 18, 2023
1 parent 55c7564 commit f627b91
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,11 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
)
// resolve asset url references
result = result.replace(assetUrlRE, (_, fileHash, postfix = '') => {
return toOutputAssetFilePath(this.getFileName(fileHash)) + postfix
const file = this.getFileName(fileHash)
if (chunk) {
chunk.viteMetadata!.importedAssets.add(cleanUrl(file))
}
return toOutputAssetFilePath(file) + postfix
})

result = result.replace(publicAssetUrlRE, (_, fileHash) => {
Expand Down
5 changes: 5 additions & 0 deletions playground/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ <h2>Image Src Set</h2>
/>
</div>

<h2>HTML only asset</h2>
<div>
<img src="./nested/html-only-asset.jpg" alt="" />
</div>

<h2>SVG Fragments</h2>
<div>
<img
Expand Down
Binary file added playground/assets/nested/html-only-asset.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f627b91

Please sign in to comment.