Skip to content
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

Macaron always reads source code from disk, making it impossible to transform the code before, using a Vite plugin for instance #76

Open
ymeine opened this issue Mar 28, 2025 · 0 comments

Comments

@ymeine
Copy link

ymeine commented Mar 28, 2025

I have a use case where I need to transform my source code defining CSS styles before Macaron catches them.

My project is relying on Vite, so naturally I created a Vite plugin to do that transformation using the transform hook, which can modify the content of a module on the fly. I also made sure this hook would get called before Macaron does its processing.

Unfortunately, as I mentioned at the beginning of my comment in a discussion in the vanilla-extract-css repository, Macaron completely circumvents the Vite modules transformation pipeline and reads the files directly on disk, making my solution impossible to implement in a clean way.

Digging a bit, I understand that the Vite plugin is just a wrapper around a Babel based solution, and that the latter only accepts a file path as input, and not the content directly.

Would it be possible to improve the babel side and accept the content instead, and the Vite side to pass in that content then, which that way can be transformed upstream by others?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant