Fixed rel="preload" as attribute for styles

This commit is contained in:
Artyom Stepanishchev
2018-12-07 23:59:51 +03:00
committed by GitHub
parent 14e809af6e
commit 8ebfcc9a54

View File

@@ -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);