Skip to content

Commit

Permalink
fix(ssr): expose context.styles when no lifecycle styles are injected
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 authored and ztlevi committed Feb 14, 2018
1 parent 0b04b76 commit a2e5760
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/server/bundle-renderer/create-bundle-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,23 @@ export function createBundleRunner (entry, files, basedir, runInNewContext) {
if (initialContext._styles) {
userContext._styles = deepClone(initialContext._styles)
}
resolve(runner(userContext))
// #6353 after the app is resolved, if the userContext doesn't have a
// styles property, it means the app doesn't have any lifecycle-injected
// styles, so vue-style-loader never defined the styles getter.
// just expose the same styles from the initialContext.
const exposeStylesAndResolve = app => {
if (!userContext.hasOwnProperty('styles')) {
userContext.styles = initialContext.styles
}
resolve(app)
}

const res = runner(userContext)
if (typeof res.then === 'function') {
res.then(exposeStylesAndResolve)
} else {
exposeStylesAndResolve(res)
}
})
}
}

0 comments on commit a2e5760

Please sign in to comment.