Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support stylesheets with link tag and media/disable prop #6751

Merged
merged 5 commits into from Jul 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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')
pd4d10 marked this conversation as resolved.
Show resolved Hide resolved
) {
// CSS references, convert to import
js += `\nimport ${JSON.stringify(url)}`
shouldRemove = true
Expand Down