windicss / vite-plugin-windicss

🍃 Windi CSS for Vite ⚡️
MIT License
852 stars 65 forks source link

Fix tag extraction for React projects #297

Closed hrishikesh-k closed 2 years ago

hrishikesh-k commented 2 years ago

WindiCSS (with React + Vite), was failing to detect my attributes in the following code:

<input
  onChange = {event => props.model[1](props.model[0], event.target.value)}
  type = {inputData.toggle ? 'text' : props.type}
  value = {props.data}
  w-bg = "white dark:black"
  w-border = {borderStyle()}
  w-font = "leading-none"
  w-h = "10"
  w-outline = "none"
  w-p = {props.type === 'password' ? 'l-10 r-17.5' : 'x-10' + ' y-2'}
  w-w = "full"/>

When I checked, it seemed to be failing at this line: https://github.com/windicss/vite-plugin-windicss/blob/main/packages/plugin-utils/src/extractors/default.ts#L12

The current regex here: https://github.com/windicss/vite-plugin-windicss/blob/main/packages/plugin-utils/src/regexes.ts#L2 stops detecting at:

<input
  onChange = {event =>

So, it has been modified to ignore the =.

hrishikesh-k commented 2 years ago

I'm not sure how to fix the tests :/

The ones using Node 12 seem to be failing due to optional chaining being used somewhere and it's not supported in Node 12. But not sure what to do about the Node 14 ones.