nuxt-modules / tailwindcss

Tailwind CSS module for Nuxt
https://tailwindcss.nuxtjs.org
MIT License
1.66k stars 180 forks source link

V6.12.1 - How to load a custom TW plugin inside a nuxt module #856

Closed JohnCampionJr closed 3 months ago

JohnCampionJr commented 3 months ago

Hi, I'm trying to update my nuxt module to v6.12.1 of your module and cannot figure out how to rework the plugin loading to avoid the HMR warning.

https://github.com/jcamp-code/nuxt-icon-tw/tree/nuxttw612

image

I had to switch to the nightly to even get this to run without a bunch of errors.

I recognize the issue is here, but I'm not sure how to rework this. https://github.com/jcamp-code/nuxt-icon-tw/blob/33685aa49d8165c335f5a9382aea0e62d741564b/src/module.ts#L154

Any guidance would be appreciated.

ineshbose commented 3 months ago

Hey, thanks for opening an issue on this repository. This message should answer exactly your question - https://github.com/nuxt-modules/tailwindcss/issues/838#issuecomment-2139672111 🙂

JohnCampionJr commented 3 months ago

I saw that before posting.

That example shows loading a config. I need to load a custom tailwind plugin.

My plugin is currently loaded and then configured before being added to tailwind.

ineshbose commented 3 months ago

Ah you're right - give me a sec. I'll clone down the repo and provide you with a solution.

JohnCampionJr commented 3 months ago

Thank you so much!!

ineshbose commented 3 months ago

No problem - https://github.com/jcamp-code/nuxt-icon-tw/pull/7

As with the comment with safelist regexes too, we make a template and provide that into our nuxt.options.tailwindcss.

The plugin code is moved to runtime directory as it's (sort of) used in the runtime lifecycle by the PostCSS loader (similar to the configMerger file in this repo). I hope this helps!

JohnCampionJr commented 3 months ago

Thanks again! Will you be publishing 6.12.1 soon or will this work on 6.12?

ineshbose commented 3 months ago

It should work with 6.12. Are we happy to close this issue?

JohnCampionJr commented 3 months ago

Yes, it does work with 6.12.0; again, thank you!