You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c63224f
Browse filesBrowse the repository at this point in the historyBrowse files
description: Enable per-directory PostCSS config resolution in Turbopack so that the config closest to each CSS file takes precedence over the project root config.
4
+
---
5
+
6
+
The `turbopackLocalPostcssConfig` option changes how Turbopack resolves `postcss.config.js` files. When enabled, Turbopack searches for the config starting from the CSS file's own directory first, then falls back to the project root. By default, Turbopack checks the project root first, meaning a root-level `postcss.config.js` always takes precedence over configs in subdirectories.
7
+
8
+
This option is only relevant when using Turbopack (`next dev` or `next build`).
With the default behavior, a `postcss.config.js` at the project root is used for all CSS files, and per-directory configs are only applied if no root config exists. Enabling `turbopackLocalPostcssConfig` reverses this: per-directory configs take precedence, and the root config serves as the fallback.
43
+
44
+
## Example
45
+
46
+
This is useful for projects that need different PostCSS transforms in different directories, such as a monorepo with multiple apps or design system packages:
47
+
48
+
```
49
+
my-app/
50
+
├── postcss.config.js ← fallback (applied if no local config is found)
51
+
├── app/
52
+
│ └── page.module.css ← uses root config
53
+
└── packages/
54
+
└── ui/
55
+
├── postcss.config.js ← takes precedence for files in this directory
|[`turbopackFileSystemCacheForDev`](/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache)| Enable filesystem cache for the dev server. |`true`| N/A |
260
-
|[`turbopackFileSystemCacheForBuild`](/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache)| Enable filesystem cache for builds. | N/A |`false`|
|[`turbopackFileSystemCacheForDev`](/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache)| Enable filesystem cache for the dev server. |`true`| N/A |
260
+
|[`turbopackFileSystemCacheForBuild`](/docs/app/api-reference/config/next-config-js/turbopackFileSystemCache)| Enable filesystem cache for builds. | N/A |`false`|
|`turbopackModuleIds`| Module ID strategy: `'named'` or `'deterministic'`. |`'named'`|`'deterministic'`|
275
+
|[`turbopackLocalPostcssConfig`](/docs/app/api-reference/config/next-config-js/turbopackLocalPostcssConfig)| Resolve `postcss.config.js` from the CSS file's directory first, then the project root. |`false`|`false`|
0 commit comments