From 667af255b3b48d74f6d782e8256d62c2d05f60e4 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 2 Dec 2024 20:23:38 +0100 Subject: [PATCH] Vite: Don't rebase absolute `url()`s (#15275) Closes #15269 This PR fixes an issue where our Vite extension was rebasing absolute urls inside `@import`-ed files. We forgot to cover this when we implemented the URL rebasing. ## Test Plan We validated that this fixes the repro in #15269: Screenshot 2024-12-02 at 18 07 35 Also added a unit test for this. Co-authored-by: Jordan Pittman --- CHANGELOG.md | 4 ++++ packages/@tailwindcss-node/src/urls.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7be15ceb6..6755c89c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Ensure absolute `url()`s inside imported CSS files are not rebased when using `@tailwindcss/vite` + ### Added - Parallelize parsing of individual source files ([#15270](https://github.com/tailwindlabs/tailwindcss/pull/15270)) diff --git a/packages/@tailwindcss-node/src/urls.ts b/packages/@tailwindcss-node/src/urls.ts index c6009a927..c4d56deb7 100644 --- a/packages/@tailwindcss-node/src/urls.ts +++ b/packages/@tailwindcss-node/src/urls.ts @@ -51,6 +51,8 @@ export async function rewriteUrls({ let promises: Promise[] = [] function replacerForDeclaration(url: string) { + if (url[0] === '/') return url + let absoluteUrl = path.posix.join(normalizePath(base), url) let relativeUrl = path.posix.relative(normalizePath(root), absoluteUrl)