Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/server/template-renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,24 @@ export default class TemplateRenderer {
}
}

renderStyles (context: Object): string {
renderCriticalStyles (context: Object): string {
// context.styles is a getter exposed by vue-style-loader which contains
// the inline component styles collected during SSR
return (context.styles || '')
}

renderStyleLinks (context: Object): string {
const initial = this.preloadFiles || []
const async = this.getUsedAsyncFiles(context) || []
const cssFiles = initial.concat(async).filter(({ file }) => isCSS(file))
return (
// render links for css files
(cssFiles.length
? cssFiles.map(({ file }) => `<link rel="stylesheet" href="${this.publicPath}${file}">`).join('')
: '') +
// context.styles is a getter exposed by vue-style-loader which contains
// the inline component styles collected during SSR
(context.styles || '')
)

return cssFiles.length
? cssFiles.map(({ file }) => `<link rel="stylesheet" href="${this.publicPath}${file}">`).join('')
: ''
}

renderStyles (context: Object): string {
return this.renderStyleLinks(context) + this.renderCriticalStyles(context)
}

renderResourceHints (context: Object): string {
Expand Down