diff --git a/src/server/template-renderer/index.js b/src/server/template-renderer/index.js index a6a1570c6b..2c95e31fd5 100644 --- a/src/server/template-renderer/index.js +++ b/src/server/template-renderer/index.js @@ -60,7 +60,7 @@ export default class TemplateRenderer { // extra functionality with client manifest if (options.clientManifest) { const clientManifest = this.clientManifest = options.clientManifest - this.publicPath = clientManifest.publicPath.replace(/\/$/, '') + this.publicPath = clientManifest.publicPath // preload/prefetch directives this.preloadFiles = (clientManifest.initial || []).map(normalizeFile) this.prefetchFiles = (clientManifest.async || []).map(normalizeFile) @@ -114,7 +114,7 @@ export default class TemplateRenderer { return ( // render links for css files (cssFiles.length - ? cssFiles.map(({ file }) => ``).join('') + ? cssFiles.map(({ file }) => ``).join('') : '') + // context.styles is a getter exposed by vue-style-loader which contains // the inline component styles collected during SSR @@ -153,7 +153,7 @@ export default class TemplateRenderer { extra = ` type="font/${extension}" crossorigin` } return `` + return `` }).join('') } else { return '' @@ -206,7 +206,7 @@ export default class TemplateRenderer { const async = (this.getUsedAsyncFiles(context) || []).filter(({ file }) => isJS(file)) const needed = [initial[0]].concat(async || [], initial.slice(1)) return needed.map(({ file }) => { - return `` + return `` }).join('') } else { return '' @@ -228,6 +228,10 @@ export default class TemplateRenderer { } return new TemplateStream(this, this.parsedTemplate, context || {}) } + + getPublicPath (file: string) { + return path.posix.join(this.publicPath, file) + } } function normalizeFile (file: string): Resource { diff --git a/test/ssr/ssr-template.spec.js b/test/ssr/ssr-template.spec.js index 63b94e112e..2491b591d8 100644 --- a/test/ssr/ssr-template.spec.js +++ b/test/ssr/ssr-template.spec.js @@ -11,6 +11,7 @@ function generateClientManifest (file, cb) { compileWithWebpack(file, { output: { path: '/', + publicPath: '/', filename: '[name].js' }, optimization: {