mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-15 20:34:44 +00:00
Fixed rel="preload" as attribute for styles
This commit is contained in:
committed by
GitHub
parent
14e809af6e
commit
8ebfcc9a54
@@ -67,7 +67,10 @@ export function get_page_handler(
|
|||||||
} else {
|
} else {
|
||||||
const link = preloaded_chunks
|
const link = preloaded_chunks
|
||||||
.filter(file => file && !file.match(/\.map$/))
|
.filter(file => file && !file.match(/\.map$/))
|
||||||
.map(file => `<${req.baseUrl}/client/${file}>;rel="preload";as="script"`)
|
.map((file) => {
|
||||||
|
const as = /\.css$/.test(file) ? 'style' : 'script';
|
||||||
|
return `<${req.baseUrl}/client/${file}>;rel="preload";as="${as}"`;
|
||||||
|
})
|
||||||
.join(', ');
|
.join(', ');
|
||||||
|
|
||||||
res.setHeader('Link', link);
|
res.setHeader('Link', link);
|
||||||
@@ -335,4 +338,4 @@ function escape_html(html: string) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return html.replace(/["'&<>]/g, c => `&${chars[c]};`);
|
return html.replace(/["'&<>]/g, c => `&${chars[c]};`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user