Skip to content

feat: add css files to server bundle for optimizeCss feature to work #904

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

Merged
merged 4 commits into from
Jun 17, 2025

Conversation

artabr
Copy link
Contributor

@artabr artabr commented Jun 13, 2025

Description

The inlining of Critical CSS with the optimizeCss feature doesn't work when using Next.js 15.3.3 (Page Router) and @opennextjs/aws 3.6.5.

The optimizeCss feature relies on the CSS files being present in the server-function bundle. During page rendering (e.g., during ISR or revalidation), a server function using the Critters library attempts to locate the CSS files used on the page and inline them in the HTML. Without these files in the server-function bundle, the inlining process fails.

These changes make the bundling process include .next/static/css files in the server-function bundle.

Detailed information is in the attached issue below.

GitHub issue

#903

Copy link

changeset-bot bot commented Jun 13, 2025

🦋 Changeset detected

Latest commit: d2d83bc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Patch
app-pages-router Patch
app-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Jun 13, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/aws@904

commit: d2d83bc

- add css files conditionally depending on optimizeCss flag
- load all manifests and configs in one place once
@artabr
Copy link
Contributor Author

artabr commented Jun 17, 2025

Hi, team, I added the changes we discussed here, and tested them on our infrastructure, works as expected. Would you be able to take a look once again at this PR?

We'll be looking forward to your comments

@artabr artabr requested review from conico974 and sommeeeer June 17, 2025 09:36
Copy link
Contributor

@sommeeeer sommeeeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sommeeeer
Copy link
Contributor

Could you add a changeset? npx changeset from root.

@artabr
Copy link
Contributor Author

artabr commented Jun 17, 2025

@sommeeeer sure, changeset added

Copy link
Contributor

@khuezy khuezy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks!

Copy link
Contributor

@conico974 conico974 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks

@conico974 conico974 merged commit 075be1e into opennextjs:main Jun 17, 2025
3 checks passed
@github-actions github-actions bot mentioned this pull request Jun 17, 2025
@artabr
Copy link
Contributor Author

artabr commented Jun 18, 2025

Thank you team for all your reviews and comments!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants