-
I try to set it up in the Next.js custom document like below, but this won't work:
|
Beta Was this translation helpful? Give feedback.
Answered by
mattp0123
Mar 19, 2022
Replies: 1 comment
-
Problem solved! import Document from 'next/document';
import postCss, { AcceptedPlugin } from 'postcss';
import postCssPresetEnv from 'postcss-preset-env';
import { getCssText } from 'styles';
export default class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const cssText = getCssText();
const { css } = await postCss([
postCssPresetEnv() as AcceptedPlugin,
]).process(cssText);
const initialProps = await Document.getInitialProps(ctx);
return {
...initialProps,
styles: (
<>
{initialProps.styles}
<style id="stitches" dangerouslySetInnerHTML={{ __html: css }} />
</>
),
};
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mattp0123
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem solved!