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",
})
minimal reproduction?
this is all i have
https://github.com/HorusGoul/vite-plugin-stylex has the exact same issue
https://github.com/HorusGoul/vite-plugin-stylex has the exact same issue
using both, didn't run into this problem by following the docs about importing variables from .stylex.js files only. Maybe you imported other things into the stylex.create() call? Try to create a reproduction.
I couldn't find any reproduction for the issue, AFAIk setting 'rootDir' manually is not necessary.