Skip to content

Instantly share code, notes, and snippets.

@theednaffattack
Created June 14, 2019 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theednaffattack/5c65da0fde178a412ad3cbd1e6c3f994 to your computer and use it in GitHub Desktop.
Save theednaffattack/5c65da0fde178a412ad3cbd1e6c3f994 to your computer and use it in GitHub Desktop.
// APP_ROOT/server.js
const { Meep: ReactSSR } = require("./src/ssr")
const sheet = new ServerStyleSheet()
try {
const html = renderToString(sheet.collectStyles(<ReactSSR />))
const styleTags = sheet.getStyleTags() // or sheet.getStyleElement();
} catch (error) {
// handle error
console.error(error)
} finally {
sheet.seal()
}
// results in Unexpected token error "<"
// =========================
// .babelrc
{
"presets": [
"@babel/preset-react",
[
"@babel/preset-env",
{
"modules": false
}
]
],
"plugins": [
[
"@babel/plugin-transform-react-jsx",
{
"pragma": "dom"
}
],
[
"babel-plugin-styled-components",
{
"pure": true
}
]
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment