Skip to content

Commit

Permalink
Fix experimental optimizeCss for SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 24, 2021
1 parent a0d44ca commit 6c9d1f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/next/next-server/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion test/integration/critical-css/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ export default function Home() {
)
}

Home.getInitialProps = () => ({})
export const getServerSideProps = () => {
return {
props: {
hello: 'world',
},
}
}
4 changes: 2 additions & 2 deletions test/integration/critical-css/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ 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" .*>/
)
expect(html).toMatch(/body{font-family:SF Pro Text/)
})

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/)
})
}
Expand Down

0 comments on commit 6c9d1f7

Please sign in to comment.