Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix experimental optimizeCss for SSR #22513

Merged
merged 2 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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