Skip to content

Commit

Permalink
fix stylesheet handling
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Aug 3, 2022
1 parent be7a64d commit d6ba0a4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/kit/src/runtime/server/page/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export async function render_response({

for (const dep of stylesheets) {
const path = options.prefix + dep;
const attributes = ['rel="stylesheet"'];
const attributes = [];

if (csp.style_needs_nonce) {
attributes.push(`nonce="${csp.nonce}"`);
Expand All @@ -232,9 +232,11 @@ export async function render_response({
// include them in disabled state so that Vite can detect them and doesn't try to add them
attributes.push('disabled', 'media="(max-width: 0)"');
} else {
link_header_preloads.add(`<${encodeURI(path)}>; ${attributes.join(';')}; nopush`);
const preload_atts = ['rel="preload"', 'as="style"'].concat(attributes);
link_header_preloads.add(`<${encodeURI(path)}>; ${preload_atts.join(';')}; nopush`);
}

attributes.unshift('rel="stylesheet"');
head += `\n\t<link href="${path}" ${attributes.join(' ')}>`;
}

Expand Down

0 comments on commit d6ba0a4

Please sign in to comment.