Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix: add lightningcss targets to prevent light-dark() lowering (#442)

David Petersen6ee2dddafb56
diff --git a/apps/example-vite/vite.config.ts b/apps/example-vite/vite.config.ts
index 9174b0c54e..b0b0a0ab73 100644
--- a/apps/example-vite/vite.config.ts
+++ b/apps/example-vite/vite.config.ts
@@ -6,6 +6,20 @@ import stylex from '@stylexjs/unplugin';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
+/**
+ * Browser targets for lightningcss.
+ * Prevents lowering native light-dark() into --lightningcss-light/--lightningcss-dark
+ * polyfill variables. XDS tokens use native light-dark() which is baseline 2024:
+ * Chrome 123+, Firefox 120+, Safari 17.5+
+ *
+ * Must match the targets in apps/storybook/.storybook/main.ts
+ */
+const lightningcssTargets = {
+ chrome: 123 << 16,
+ firefox: 120 << 16,
+ safari: (17 << 16) | (5 << 8),
+};
+
// https://vite.dev/config/
export default defineConfig({
plugins: [
@@ -17,6 +31,9 @@ export default defineConfig({
type: 'commonJS',
rootDir: __dirname,
},
+ lightningcssOptions: {
+ targets: lightningcssTargets,
+ },
}),
react(),
],
diff --git a/internal/vibe-tests/app/vite.config.ts b/internal/vibe-tests/app/vite.config.ts
index 0d88aa0e46..e9c71275dd 100644
--- a/internal/vibe-tests/app/vite.config.ts
+++ b/internal/vibe-tests/app/vite.config.ts
@@ -8,6 +8,20 @@ import {viteSingleFile} from 'vite-plugin-singlefile';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const repoRoot = path.resolve(__dirname, '../../..');
+/**
+ * Browser targets for lightningcss.
+ * Prevents lowering native light-dark() into --lightningcss-light/--lightningcss-dark
+ * polyfill variables. XDS tokens use native light-dark() which is baseline 2024:
+ * Chrome 123+, Firefox 120+, Safari 17.5+
+ *
+ * Must match the targets in apps/storybook/.storybook/main.ts
+ */
+const lightningcssTargets = {
+ chrome: 123 << 16,
+ firefox: 120 << 16,
+ safari: (17 << 16) | (5 << 8),
+};
+
export default defineConfig({
plugins: [
stylex.vite({
@@ -24,6 +38,9 @@ export default defineConfig({
'packages/core/src/theme/tokens.stylex.ts',
),
},
+ lightningcssOptions: {
+ targets: lightningcssTargets,
+ },
}),
react(),
viteSingleFile(),