windicss / vite-plugin-windicss

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

Pug not detected per default with Nuxt3 #266

Open jbmolle opened 2 years ago

jbmolle commented 2 years ago

Describe the bug Check https://github.com/windicss/nuxt-windicss/issues/144 When using pug class syntax in Nuxt3 with nuxt-windicss, WindiCSS doesn't not add the CSS classes. For example the following p(class="text-red-600") My Text works fine and displays a red text But the following p.text-red-600 My Text does not.

Versions

Additonal Context The problem comes from getDefaultExtractors in vite-plugin-windicss/packages/plugin-utils/src/extractors/helper.ts Nuxt uses dist/index.mjs from @windicss/plugin-utils and require('pug') line 17 fails (it calls __require which doesn't work). So the Pug extractor is not added. One solution currently is to add the extractor manually in the WindiCSS config.

xxSkyy commented 2 years ago

After time I think it this bug could be a feature, not supporting .class will keep code consistency as for example colons are not permitted in this syntax, keeping all classes in class attribute keeps it more clean as classes won't be divided at one with special character and without.