question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSR context.renderStyles() returns empty string

See original GitHub issue

Version

2.4.1

Reproduction link

http://plnkr.co/edit/Gtp3uFFiBIxYMmyh3Se9

Steps to reproduce

webpack config rules : {test: /.css$/, loader: “vue-style-loader!css-loader”}

<script>
import './common.css';
export default {
	name: 'app',
};
</script>
<template src="./app.html"></template>

context has _styles property but context.renderStyles() returns empty string why is it? client side works fine. I don’t know what I missed. please help.

有context._styles,不过context.renderStyles()的结果是“” 为什么? 浏览器上是正常添加STYLE。 不知道错过了什么,求解 1 2

What is expected?

context.renderStyles() => “<style>body {…}</style>”

What is actually happening?

context.renderStyles() => “”

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
yyx990803commented, Jul 21, 2017

Ok, so I looked at your setup and it’s because in here you are using extends: app so essentially your app component is also the root component. The SSR CSS is injected in each component’s beforeCreate hook, however you created the root instance before the render starts, so the injected CSS never got registered.

What you need to do is make the root component a wrapper:

// from this
app: new Vue({router, extends: app, store})

// to this
app: new Vue({router, store, render: h => h(app) })
0reactions
Elevistacommented, Jul 21, 2017

@yyx990803 Thank you very very much ❤️ work like a charm You’re the king god maestro emperor code meister! Vue.js forever xD

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server Side Rendering - renderToString returns empty html
I'm trying to render react application on server, but it seems that renderToString function doesn't render markup properly, ...
Read more >
@minstack/styled - npm
If a CSS property value is "empty" (empty string, false , null , undefined ... The SSR manager's getStyleTags() method returns a single...
Read more >
Server-Side Rendering (SSR) - Vue.js
renderToString() takes a Vue app instance and returns a Promise that resolves to the rendered HTML of the app. It is also possible...
Read more >
Demystifying server-side rendering in React - freeCodeCamp
Server-Side Rendering — SSR from here on — is the ability of a ... The initial server request is generally returning an empty...
Read more >
Server Side Rendering - Search.io React SDK
This signals to all nested components that they are being rendered in an SSR context. If you're using @sajari/react-search-ui ... Copy.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found