vite-plugin-stylex icon indicating copy to clipboard operation
vite-plugin-stylex copied to clipboard

Variables not Working

Open eduveks opened this issue 1 year ago • 9 comments

Hi,

It is impossible to use variables because when using variables raises the error:

[plugin:vite-plugin-stylex] /index.stylex.js: Only static values are allowed inside of a stylex.create() call.

My tokens.stylex.js:

import * as stylex from '@stylexjs/stylex';
export const colors = stylex.defineVars({
  primary: { default: '#F8B420' }
});

Using the colors.primary variable:

import * as stylex from '@stylexjs/stylex';

import { colors } from '../../styles/tokens.stylex';

const styles = stylex.create({
  content: {
    color: colors.primary,
  }
});

export default styles;

eduveks avatar Feb 08 '24 20:02 eduveks