Skip to content

Vite 8.2.x leaves CSS asset URLs stale after PostCSS transforms #23348

Description

@Razunter

Describe the bug

most of the issue is written by AI

Vite 8.2.x can emit hashed CSS assets while leaving the original source-relative url() unchanged. The generated CSS then points at a source path that is not present beside the output CSS file.

The regression reproduces in two independent configurations:

  1. Sass with postcss-lightningcss.
  2. @tailwindcss/vite with an empty PostCSS configuration.

Both fixtures produce the expected asset URLs with Vite 8.1.5. With Vite 8.2.2, the asset files are still emitted but the CSS references stale relative URLs.

Reproduction

https://github.com/Razunter/vite-82-css-bug-repro

Steps to reproduce

  1. Clone the reproduction repo.

  2. Install dependencies:

    npm install
  3. Run the four comparison builds:

    npm run build:postcss:8.1.5
    npm run build:postcss:8.2.2
    npm run build:tailwind:8.1.5
    npm run build:tailwind:8.2.2
  4. Inspect the generated CSS files under the four dist-* directories.

Each script invokes its Vite version through npx --yes; the fixture manifest itself remains pinned to Vite 8.2.2.

System Info

System:
  OS: Linux 6.18.33.1-microsoft-standard-WSL2 x64
  Environment: DDEV on WSL2
Binaries:
  Node: 24.18.0
  npm: 11.16.0
Packages:
  vite: 8.2.2
  rolldown: 1.2.5
  @tailwindcss/vite: 4.3.3
  postcss-lightningcss: 1.1.1
  sass: 1.103.0
  tailwindcss: 4.3.3

Used Package Manager

npm

Logs

The builds complete successfully; the failure is visible in the emitted CSS.

Vite 8.1.5 / PostCSS:
  url(/assets/Roboto-Regular-BKwBj7lc.ttf)
  url(/vite-css-url-repro.webp)

Vite 8.2.2 / PostCSS:
  url(../fonts/Roboto-Regular.ttf)
  url(/vite-css-url-repro.webp)

Vite 8.1.5 / Tailwind:
  url(/assets/vite-css-url-repro-HxSRdrt5.webp)
  url(/vite-css-url-repro.webp)

Vite 8.2.2 / Tailwind:
  url(../images/vite-css-url-repro.webp)
  url(/vite-css-url-repro.webp)

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions