Skip to content

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

Description

@ymeine

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions