bug: CSS unit being removed during build process when value is 0

Open
#23,936 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
57/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
css, typescript, vite

Research direction

Start with the linked reproduction and compare how yarn dev and yarn build process the global CSS, focusing on the build pipeline’s CSS optimization step. Identify which stage removes the unit from 0px in border-image-outset, then add a regression case for the reported keyframe and verify the built CSS preserves the intended behavior.

Written by the indexing model from the issue text.

Description

bug: upstream feat: css
Describe the bug

I have this code in a global CSS file:

@keyframes donateBorder {
    from {
        border-image-outset: 0 200px;
    }
    to {
        border-image-outset: 0 0px;
    }
}

in a dev server, this works without issue; however, once built, this becomes:

@keyframes donateBorder {
    from {
        border-image-outset: 0 200px;
    }
    to {
        border-image-outset: 0 0;
    }
}

...which doesn't work, because the unit is not specified.

Reproduction

https://github.com/rexogamer/vite-css-repro

Steps to reproduce
  • yarn && yarn dev
  • inspect the styles in the browser and scroll down to the keyframe
  • observe that the units are specified correctly
  • yarn build && yarn preview
  • inspect the styles in the browser
  • observe that the units are dropped
System Info
System:
    OS: Linux 7.0 Ubuntu 26.04.1 LTS 26.04.1 LTS (Resolute Raccoon)
    CPU: (8) x64 Intel(R) Core(TM) Ultra 7 256V
    Memory: 4.53 GB / 14.47 GB
    Container: Yes
    Shell: 5.3.9 - /bin/bash
  Binaries:
    Node: 24.22.1 - /home/rexo/.nvm/versions/node/v24.22.1/bin/node
    Yarn: 1.22.22 - /home/rexo/.nvm/versions/node/v24.22.1/bin/yarn
    npm: 11.19.1 - /home/rexo/.nvm/versions/node/v24.22.1/bin/npm
    pnpm: 12.16.1 - /home/rexo/.nvm/versions/node/v24.22.1/bin/pnpm
    Deno: 2.9.5 - /home/rexo/.deno/bin/deno
  Browsers:
    Chromium: 158.0.8106.0
  npmPackages:
    vite: ^8.3.5 => 8.3.5
Used Package Manager

yarn

Logs

No response

Validations
Dominant language
TypeScript
Stars
84k
Forks
9.2k
Avg merge
1d 9h
Merged PRs (30d)
103

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vitejs/vite

All issues in vitejs/vite

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.