vite-plugin-windicss
vite-plugin-windicss copied to clipboard
Pug not detected per default with Nuxt3
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
- nuxt-windicss: 2.1.1
- nuxt3: latest
- vite-plugin-windicss: 1.5.4
- vite: 2.7.3
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.
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.