Feature request: Custom injection target
m44rten1 opened this issue · 3 comments
Hello,
First off, I'd like to express my appreciation for your work on the ShadowStyle plugin. However, I've encountered a scenario where being able to specify a custom injection target would greatly enhance its utility in my project.
My project involves lazy loading styles, and as a result, I don't inject them at the entry point. This leads to a need for more flexibility in terms of where the styles are injected. To address this, I propose adding an option to the ShadowStyle plugin that allows users to define a custom injection target.
Here's a rough idea of how this feature could be implemented:
...
plugins: [
shadowStyle({ injectionTarget: 'my-injection-target' }),
],
...
Hey, thank you for using the plug-in and providing this idea! What would the injection target refer to, in your example? A DOM node, or a placeholder string to swap with the actual output CSS?
Hey! I see that my comment wasn't clear. my-injection-target
would refer to a file-name. I believe that the plugin only allows 'entry' files, if I understand the isInjectionTarget
method.
Yes, isInjectionTarget
currently scans for output files and returns true
if the file has the isEntry
flag set by Vite. We can definitely customise this behaviour and allow for custom definition of an entrypoint.