Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const noInlineLinkRels = new Set([
'apple-touch-icon',
'apple-touch-startup-image',
'manifest',
'modulepreload',
])

export const isAsyncScriptMap: WeakMap<
Expand Down
10 changes: 10 additions & 0 deletions playground/assets/__tests__/assets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ describe('css url() references', () => {
expect(await getBg('.css-url-quotes-base64-inline')).toMatch(match)
})

test('no base64 inline for modulepreload links', async () => {
const el = await page.$(`link[rel="modulepreload"]`)
const href = await el.getAttribute('href')
expect(href).toMatch(
isBundled
? /\/foo\/bar\/assets\/preload-module-[-\w]{8}\.js/
: 'preload-module.js',
)
})

test('no base64 inline for icon and manifest links', async () => {
const iconEl = await page.$(`link.ico`)
const href = await iconEl.getAttribute('href')
Expand Down
1 change: 1 addition & 0 deletions playground/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<link class="ico" rel="icon" type="image/svg+xml" href="favicon.ico" />
<link rel="manifest" href="manifest.json" />
<link rel="modulepreload" href="preload-module.js" />
<meta
class="meta-og-image"
property="og:image"
Expand Down
2 changes: 2 additions & 0 deletions playground/assets/preload-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// referenced via <link rel="modulepreload">, small enough to hit assetsInlineLimit
export const preloadedModule = 'preloaded'