Closed maiertech closed 4 months ago
my guess is that the tests don't need any processed CSS but are still being run as part of a build pipeline, so when they're being run for tests there's no source stylesheet and jit props is complaining there's no where to put props as it's being called without a stylesheet. can you disable postcss processes for tests? or provide a dummy stylesheet to pacify / spoof the postcss build process?
not sure it'd be a good idea to build resilience into jit-props to handle this, like I'd still want the plugin to report an error or something that "no work is being done because there's no source". maybe throwing an error is better than dying tho and would unblock this scenario.
you could also try an alternative postcss config for your test runner to use, and it omits jit-props since you're not needing that during unit testing?
I decided to make use of PropPacks in OpenProps instead of this plugin. That's a good enough optimization in my use case.
I added
postcss-jit-props
with OpenProps to a SvelteKit app with thispostcss.config.js
and it seems to work fine:But one of my Vitest tests breaks with this error message:
I can make the test pass by removing
postcss-jit-props
from the above config.Now the thing is that my Vitest tests don't have any business with PostCSS except that the one that breaks uses
import.meta.glob
, which triggers Vite's preprocessing chain.The line that causes trouble in
postcss-jit-props
'sindex.js
is 130:But this where I am a bit lost. The repo where it happens is private. I can try to create a repro, but it would be a SvelteKit app.