vite-plugin-stylex
vite-plugin-stylex copied to clipboard
Cannot use variables
[vite] Internal server error: /home/aspizu/Documents/Projects/stylex-components/src/Base.tsx: Only static values are allowed inside of a stylex.create() call.
Plugin: vite-plugin-stylex
import react from "@vitejs/plugin-react"
import {defineConfig} from "vite"
import {stylexPlugin} from "vite-plugin-stylex-dev"
export default defineConfig({
plugins: [
react(),
stylexPlugin({
unstable_moduleResolution: {
type: "commonJS",
rootDir: "/src",
},
}),
],
build: {
target: "esnext",
},
})
import {colors, fontFamily} from "./tokens.stylex.ts"
import * as stylex from "@stylexjs/stylex"
export const fontFamily = stylex.defineVars({
sans: "Inter",
serif: "Merriweather",
mono: "Cascadia Code",
})
export const colors = stylex.defineVars({
background: "#000000",
foreground: "#ffffff",
})