Skip to content

Commit

Permalink
fix: should allow srcset on source tag
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Apr 10, 2021
1 parent fe0e754 commit 88a0132
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ export async function urlToBuiltUrl(
const file = url.startsWith('/')
? path.join(config.root, url)
: path.join(path.dirname(importer), url)
const stats = await fsp.stat(file)
if (stats.isDirectory()) {
return url
}

return fileToBuiltUrl(
file,
config,
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function htmlInlineScriptProxyPlugin(): Plugin {
export const assetAttrsConfig: Record<string, string[]> = {
link: ['href'],
video: ['src', 'poster'],
source: ['src'],
source: ['src', 'srcset'],
img: ['src', 'srcset'],
image: ['xlink:href', 'href'],
use: ['xlink:href', 'href']
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export async function processSrcSet(
.split(' ', 2)
return { url, descriptor }
})
.filter(({ url, descriptor }) => url && descriptor)
.filter(({ url }) => !!url)

const ret = await Promise.all(
imageCandidates.map(async ({ url, descriptor }) => {
Expand Down

0 comments on commit 88a0132

Please sign in to comment.