Skip to content

Commit

Permalink
fix: link tag with media prop
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Feb 4, 2022
1 parent 104bdb5 commit bae30d7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vite/src/node/plugins/html.ts
Expand Up @@ -322,7 +322,13 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
// assetsUrl may be encodeURI
const url = decodeURI(p.value.content)
if (!isExcludedUrl(url)) {
if (node.tag === 'link' && isCSSRequest(url)) {
if (
node.tag === 'link' &&
isCSSRequest(url) &&
// should not be converted if media attribute is present
// see #6748
!node.props.some((p) => p.name === 'media')
) {
// CSS references, convert to import
js += `\nimport ${JSON.stringify(url)}`
shouldRemove = true
Expand Down

0 comments on commit bae30d7

Please sign in to comment.