Skip to content

Commit

Permalink
Invalidate cache for link[preload] in dev for CSS files (#10630)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Haddad <timer150@gmail.com>
  • Loading branch information
bmathews and Timer committed Feb 22, 2020
1 parent 89c792f commit d467e04
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/next/pages/_document.tsx
Expand Up @@ -186,6 +186,7 @@ export class Head extends Component<

getCssLinks(): JSX.Element[] | null {
const { assetPrefix, files } = this.context._documentProps
const { _devOnlyInvalidateCacheQueryString } = this.context
const cssFiles =
files && files.length ? files.filter(f => /\.css$/.test(f)) : []

Expand All @@ -196,15 +197,19 @@ export class Head extends Component<
key={`${file}-preload`}
nonce={this.props.nonce}
rel="preload"
href={`${assetPrefix}/_next/${encodeURI(file)}`}
href={`${assetPrefix}/_next/${encodeURI(
file
)}${_devOnlyInvalidateCacheQueryString}`}
as="style"
crossOrigin={this.props.crossOrigin || process.crossOrigin}
/>,
<link
key={file}
nonce={this.props.nonce}
rel="stylesheet"
href={`${assetPrefix}/_next/${encodeURI(file)}`}
href={`${assetPrefix}/_next/${encodeURI(
file
)}${_devOnlyInvalidateCacheQueryString}`}
crossOrigin={this.props.crossOrigin || process.crossOrigin}
/>
)
Expand Down

0 comments on commit d467e04

Please sign in to comment.