提交 3910b6de 编写于 作者: Y Yuki Takemoto 提交者: Joe Haddad

Upgrade next of with-typescript-styled-components sample (#7788)

上级 7da546a3
{
"presets": ["next/babel", "@zeit/next-typescript/babel"],
"presets": ["next/babel"],
"plugins": [["styled-components", { "ssr": true }]]
}
/// <reference types="next" />
/// <reference types="next/types/global" />
const withTypescript = require('@zeit/next-typescript')
module.exports = withTypescript()
......@@ -7,17 +7,18 @@
"start": "next start"
},
"dependencies": {
"@types/next": "^8.0.1",
"@types/react": "^16.8.6",
"@types/styled-components": "^4.1.11",
"@zeit/next-typescript": "^1.1.1",
"next": "^8.0.3",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"next": "9.0.0",
"react": "16.8.6",
"react-dom": "16.8.6",
"styled-components": "^4.1.3"
},
"devDependencies": {
"babel-plugin-styled-components": "^1.10.0"
"@types/node": "12.0.12",
"@types/react": "16.8.23",
"@types/react-dom": "16.8.4",
"@types/styled-components": "4.1.16",
"babel-plugin-styled-components": "^1.10.0",
"typescript": "3.5.2"
},
"license": "ISC"
}
}
\ No newline at end of file
import Document, { NextDocumentContext } from 'next/document'
import Document, { DocumentContext } from 'next/document'
import { ServerStyleSheet } from 'styled-components'
export default class MyDocument extends Document {
static async getInitialProps(ctx: NextDocumentContext) {
static async getInitialProps(ctx: DocumentContext) {
const sheet = new ServerStyleSheet()
const originalRenderPage = ctx.renderPage
......@@ -15,12 +15,12 @@ export default class MyDocument extends Document {
const initialProps = await Document.getInitialProps(ctx)
return {
...initialProps,
styles: (
styles: [
<>
{initialProps.styles}
{sheet.getStyleElement()}
</>
),
</>,
],
}
} finally {
sheet.seal()
......
......@@ -3,7 +3,10 @@
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"lib": ["dom", "es2017"],
"lib": [
"dom",
"es2017"
],
"moduleResolution": "node",
"allowJs": true,
"noEmit": true,
......@@ -15,6 +18,17 @@
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"esModuleInterop": true
}
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册