Fix experimental optimizeCss for SSR (#22513)
This ensures `distDir` is set under `renderOpts` in `next-server` so that it is present when experimental `optimizeCss` is enabled. x-ref: https://github.com/vercel/next.js/pull/16539
This commit is contained in:
parent
c81eadc6dc
commit
6d068aed4f
3 changed files with 11 additions and 3 deletions
|
@ -161,6 +161,7 @@ export default class Server {
|
|||
locales?: string[]
|
||||
defaultLocale?: string
|
||||
domainLocales?: DomainLocales
|
||||
distDir: string
|
||||
}
|
||||
private compression?: Middleware
|
||||
private onErrorMiddleware?: ({ err }: { err: Error }) => Promise<void>
|
||||
|
@ -218,6 +219,7 @@ export default class Server {
|
|||
optimizeImages: this.nextConfig.experimental.optimizeImages,
|
||||
optimizeCss: this.nextConfig.experimental.optimizeCss,
|
||||
domainLocales: this.nextConfig.i18n?.domains,
|
||||
distDir: this.distDir,
|
||||
}
|
||||
|
||||
// Only the `publicRuntimeConfig` key is exposed to the client side
|
||||
|
|
|
@ -8,4 +8,10 @@ export default function Home() {
|
|||
)
|
||||
}
|
||||
|
||||
Home.getInitialProps = () => ({})
|
||||
export const getServerSideProps = () => {
|
||||
return {
|
||||
props: {
|
||||
hello: 'world',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ let app
|
|||
|
||||
function runTests() {
|
||||
it('should inline critical CSS', async () => {
|
||||
const html = await renderViaHTTP(appPort, '/index')
|
||||
const html = await renderViaHTTP(appPort, '/')
|
||||
expect(html).toMatch(
|
||||
/<link rel="stylesheet" href="\/_next\/static\/css\/.*\.css" .*>/
|
||||
)
|
||||
|
@ -27,7 +27,7 @@ function runTests() {
|
|||
})
|
||||
|
||||
it('should not inline non-critical css', async () => {
|
||||
const html = await renderViaHTTP(appPort, '/index')
|
||||
const html = await renderViaHTTP(appPort, '/')
|
||||
expect(html).not.toMatch(/.extra-style/)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue