Commit 6ff89b1f authored by Matt's avatar Matt Committed by Tim Neutkens

Update with-emotion to flush SSR styles on refresh (#2565)

* Update with-emotion to flush SSR styles on refresh

* with-emtotion: remove @apply, use composes

* fix env determination
parent b47395ab
import Document, { Head, Main, NextScript } from 'next/document' import Document, { Head, Main, NextScript } from 'next/document'
import { extractCritical } from 'emotion/server' import { extractCritical } from 'emotion/server'
import { flush } from 'emotion'
const dev = process.env.NODE_ENV !== 'production'
export default class MyDocument extends Document { export default class MyDocument extends Document {
static getInitialProps ({ renderPage }) { static getInitialProps ({ renderPage }) {
if (dev) { flush() }
const page = renderPage() const page = renderPage()
const styles = extractCritical(page.html) const styles = extractCritical(page.html)
return { ...page, ...styles } return { ...page, ...styles }
......
...@@ -48,7 +48,7 @@ export default () => { ...@@ -48,7 +48,7 @@ export default () => {
} }
` `
const Basic = styled.div`@apply ${basicStyles};` const Basic = styled.div`composes: ${basicStyles};`
const Combined = styled.div` const Combined = styled.div`
composes: ${basicStyles} ${hoverStyles}; composes: ${basicStyles} ${hoverStyles};
& code { & code {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment