Skip to content

Commit

Permalink
refactor: avoid preloading already present css
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 10, 2021
1 parent 2da0f2f commit a8f304e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/importAnaysisBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ function __vitePreload(baseModule: () => Promise<{}>, deps?: string[]) {
if (dep in seen) return
// @ts-ignore
seen[dep] = true
const isCss = /\.css$/.test(dep)
// @ts-ignore check if the css file is already linked in SSR markup
if (isCss && document.querySelector(`link[href="${dep}"]`)) {
return
}
// @ts-ignore
const link = document.createElement('link')
const isCss = /\.css$/.test(dep)
link.rel = isCss
? 'stylesheet'
: link.relList &&
Expand Down

0 comments on commit a8f304e

Please sign in to comment.