diff --git a/server/document.js b/server/document.js index 92f6a906..5dc0a6c0 100644 --- a/server/document.js +++ b/server/document.js @@ -39,6 +39,10 @@ export class Head extends Component { _documentProps: PropTypes.any } + static propTypes = { + nonce: PropTypes.string + } + getChunkPreloadLink (filename) { const { __NEXT_DATA__, buildManifest } = this.context._documentProps let { assetPrefix, buildId } = __NEXT_DATA__ @@ -48,6 +52,7 @@ export class Head extends Component { return files.map(file => { return )) } @@ -90,9 +96,9 @@ export class Head extends Component { return
{(head || []).map((h, i) => React.cloneElement(h, { key: h.key || i }))} - {page !== '/_error' && } - - + {page !== '/_error' && } + + {this.getPreloadDynamicChunks()} {this.getPreloadMainLinks()} {styles || null} @@ -136,6 +142,7 @@ export class NextScript extends Component { )) @@ -165,6 +172,7 @@ export class NextScript extends Component { async key={chunk} src={`${assetPrefix}/_next/webpack/chunks/${chunk}`} + nonce={this.props.nonce} /> ))} @@ -204,9 +212,9 @@ export class NextScript extends Component { `} ` }} />} - {page !== '/_error' && } - - + {page !== '/_error' && } + + {staticMarkup ? null : this.getDynamicChunks()} {staticMarkup ? null : this.getScripts()} diff --git a/test/integration/app-document/pages/_document.js b/test/integration/app-document/pages/_document.js index 05ac34d0..10c4be43 100644 --- a/test/integration/app-document/pages/_document.js +++ b/test/integration/app-document/pages/_document.js @@ -9,14 +9,14 @@ export default class MyDocument extends Document { render () { return ( - +{this.props.customProperty}
Hello Document HMR
-