-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT duplicates variables when used with SvelteKit #315
Comments
CSS modules make JIT difficult because each css file is individually evaluated and the postcss plugin isn't given awareness of this, so each file gets its own scope. AKA, this does happen in other frameworks, like Next that uses CSS modules. Next has a concept of You could work around this by running a follow up plugin on the output of the css processes, that combines media queries and then another pass with like UnCSS which can remove duplicates. Again tho yeah, the problem is that the plugins are ran per file without any context or provided any stylesheet that's a global file to put the discovered props into. With CSS modules, i think the best route forward for a minimal amount of props shipped, is to individually import a color palette, or sizes, from open props, and drop them into a global file you have. then all the module files can just use them, without jit props, and you can add or remove prop packs as you need. this will lead to shipping more reds, for exaple, then you may be using, but it's not going to bulk up your stylesheet by an amount to be worried about. |
Is there a way to implement the way Tailwind does it? |
probably! it's all code and connective tissue could get made so that jit-props gets given a file like |
going to close this here as we should continue to convo in the jit-props plugin |
I am not sure if this happens with other frameworks as well. In SvelteKit, using the following
postcss.config.cjs
file:And the following
svelte.config.js
file:And with two
.svelte
files, each defining a class withcolor: var(--red-6);
, I get the following CSS output in both development and production:In Tailwind's SvelteKit setup docs their jit setup generates a single CSS file to import into your app. Is something like this possible with Open Props? Essentially generate a single CSS file that contains only the props I use and then include that CSS file in the app.
The text was updated successfully, but these errors were encountered: