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

Docs: Document cssChunking option #67691

Merged
merged 9 commits into from
Jul 15, 2024
Merged

Docs: Document cssChunking option #67691

merged 9 commits into from
Jul 15, 2024

Conversation

delbaoliveira
Copy link
Contributor

Closes: NDX-13
Related: NDX-1

@delbaoliveira delbaoliveira requested a review from samcx July 12, 2024 08:37
@ijjk ijjk added created-by: Next.js Docs team PRs by the Docs team. Documentation Related to Next.js' official documentation. labels Jul 12, 2024
@delbaoliveira delbaoliveira requested a review from sokra July 12, 2024 08:41
@samcx
Copy link
Member

samcx commented Jul 12, 2024

cc @delbaoliveira

It's used in the code comments, struggled with explaining this, open to suggestions for alternatives.

What are the cases when "loose" might break someone's CSS?

@sokra Is there a better word than "guessing" (I'm not sure if the code is really guessing per-say unless there is something like Math.random() in there?) or is that the best word to use here? Also, if you have any idea, would be nice to know if there's any specific scenario where "loose" might break.

@sokra
Copy link
Member

sokra commented Jul 15, 2024

Is there a better word than "guessing"

It's figuring out the dependencies from the import order in source code.

Copy link
Member

@samcx samcx left a comment

Choose a reason for hiding this comment

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

:lfgtm:!

@samcx samcx enabled auto-merge (squash) July 15, 2024 13:11
@samcx samcx merged commit b7f9f1f into canary Jul 15, 2024
50 of 54 checks passed
@samcx samcx deleted the docs-1ids branch July 15, 2024 13:12
- **`'loose'` (default)**: Next.js will try to merge CSS files whenever possible, determining explicit and implicit dependencies between files from import order to reduce the number of chunks and therefore the number of requests.
- **`'strict'`**: Next.js will load CSS files in the correct order they are imported into your files, which can lead to more chunks and requests.

You may consider using `'strict'` if you run into unexpected CSS behavior. For example, if you import `a.css` and `b.css` in different files using a different `import` order (`a` before `b`, or `b` before `a`), `'loose'` will merge the files in any other and assume there are no dependencies between them. However, if `b.css` depends on `a.css`, you may want to use `'strict'` to prevent the files from being merged, and instead, load them in the order they are imported - which can result in more chunks and requests.

Choose a reason for hiding this comment

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

@delbaoliveira Sorry for randomly appearing in a merged PR, but I'm guessing there is a typo here.

"will merge the files in any other" should most likely be "will merge the files in any order".

@samcx samcx mentioned this pull request Jul 25, 2024
samcx added a commit that referenced this pull request Jul 25, 2024
## Why?

Fixing `other` → `order` typo.

- x-ref:
#67691 (comment)
@github-actions github-actions bot added the locked label Aug 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2024
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Next.js Docs team PRs by the Docs team. Documentation Related to Next.js' official documentation. locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants