AdrianGonz97/vite-plugin-tailwind-purgecss

bug: Classes are mistakenly purged when a component module is referenced, but not present in the template

AdrianGonz97 opened this issue · 0 comments

This is definitely a strange one. Will take some time to figure it out.

Some observations:

  • Adding the component somewhere in the template fixes it.
<script>
	import TestModal from "./TestModal.svelte";
</script>
<TestModal />
  • Adding a reference to the component outside of the onMount also fixes it.
<script>
	import TestModal from "./TestModal.svelte";
	TestModal.name;
</script>
  • For SvelteKit, the component module TestModal isn't parsed at all during the server build. It only shows up during the client build (presumably because the module reference is wrapped in an onMount, which gets plucked out by SK), but the classes somehow never make it through into the final client bundle

Reproduction:

git clone https://github.com/knd775/vite-purgecss-repro