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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

artabr
Copy link

@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

⚠️ No Changeset found

Latest commit: 4142942

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@@ -360,6 +361,14 @@ File ${serverPath} does not exist
.forEach((file) => copyStaticFile(`server/${file}`));
}

// Copy .next/static/css from standalone to output dir
// needed for optimizeCss feature to work
cpSync(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should only copy this if optimizeCss is true. We don't want to add unnecessary files to the bundle

Copy link
Author

Choose a reason for hiding this comment

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

Got you, I will make changes then

Copy link

pkg-pr-new bot commented Jun 13, 2025

Open in StackBlitz

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

commit: 4142942

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.

2 participants