next.js
24c6e3e4 - Add CSS URL deployment ID suffix support (#89771)

Commit
2 days ago
Add CSS URL deployment ID suffix support (#89771) ## Summary Adds deployment ID suffix (`?dpl=<deployment_id>`) to asset URLs referenced in CSS `url()` declarations (images, fonts) for both Turbopack and Webpack builds. This enables proper cache busting for CSS-referenced assets when using `deploymentId` in `next.config.js`. ### Turbopack - Added `static_suffix` field to the existing `UrlBehavior` struct, providing a build-time constant suffix for contexts that cannot use dynamic JS expressions (e.g., CSS `url()` references) - CSS URL resolution now calls `url_behavior(None)` and uses `static_suffix` instead of a separate method - Wired the suffix from `next.config.js` `deploymentId` through `asset_suffix_path()` into all three chunking contexts (client, server, edge) via `default_url_behavior` and `url_behavior_override` ### Webpack - Passed `deploymentId` through the CSS loader config pipeline (`webpack-config.ts` → `config/index.ts` → `css/loaders/` → `postcss-url-parser.ts`) - Appended `?dpl=<id>` to resolved asset URLs in the PostCSS URL parser plugin, placed before any hash fragment so it remains a server-visible query parameter ### Test - Added production test (`test/production/css-url-deployment-id/`) covering global CSS, CSS modules, and SCSS modules with image and font `url()` references - Verifies all asset URLs contain the `dpl` query parameter in both Turbopack and Webpack modes
Author
Parents
Loading