-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
bug: upstreamBug in a dependency of ViteBug in a dependency of Vitefeat: cssp3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
I noticed an unnecessary duplication of @supports rules when using the Lightning CSS minification, which also differs from the LightningCSS playground output.
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import browserslist from 'browserslist';
import { browserslistToTargets } from 'lightningcss';
// https://vitejs.dev/config/
export default defineConfig({
css: {
transformer: 'lightningcss',
lightningcss: {
targets: browserslistToTargets(browserslist('>= 0.25%')),
drafts: {
customMedia: true,
},
},
},
build: {
cssMinify: 'lightningcss',
// cssMinify: true,
},
plugins: [react()],
});1st test (OKLCH):
Input:
.x {
--x: oklch(61% 0.016 277.7);
}Result:
.x {
--x: #81828d;
}
@supports (color: lab(0% 0 0)) {
.x {
--x: #81828d;
}
@supports (color: color(display-p3 0 0 0)) {
.x {
--x: color(display-p3 0.50541 0.511328 0.549274);
}
}
@supports (color: lab(0% 0 0)) {
.x {
--x: lab(54.6419% 0.899702 -5.96);
}
}
}Expected result (LightningCSS playground):
.x {
--x: #81828d;
}
@supports (color: lab(0% 0 0)) {
.x {
--x: lab(54.6419% 0.899702 -5.96);
}
}///
2nd case (display-p3):
Input:
.x {
--x: color(display-p3 0.004 0.278 0.933 / 0.173);
}Result:
.x {
--x: #0051e52c;
}
@supports (color: color(display-p3 0 0 0)) {
.x {
--x: #0051e52c;
}
@supports (color: color(display-p3 0 0 0)) {
.x {
--x: color(display-p3 0.004 0.278 0.933/.173);
}
}
}Expected result (LightningCSS playground):
.x {
--x: rgba(0, 81, 229, 0.173);
}
@supports (color: color(display-p3 0 0 0)) {
.x {
--x: color(display-p3 0.004 0.278 0.933/.173);
}
}Reproduction
https://stackblitz.com/edit/vitejs-vite-wdjgbn?file=src%2FApp.css,vite.config.ts
Steps to reproduce
Run pnpm build to inspect /dist folder for CSS output
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.3 - /usr/local/bin/pnpm
npmPackages:
@vitejs/plugin-react: ^4.2.1 => 4.2.1
vite: ^5.2.7 => 5.2.8Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug: upstreamBug in a dependency of ViteBug in a dependency of Vitefeat: cssp3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)