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

Support for dev server #128

Closed
bytestream opened this issue Nov 22, 2023 · 10 comments
Closed

Support for dev server #128

bytestream opened this issue Nov 22, 2023 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@bytestream
Copy link

🚀 Feature Request

Is your feature request related to a problem? Please describe.

I would like to append css to the shadow dom - a feature which is currently unsupported by Vite (vitejs/vite#11855). This plugin currently works great on vibe build, but does not run at all on vite (development server). My understanding that this is by design - https://github.com/marco-prontera/vite-plugin-css-injected-by-js/blob/main/src/index.ts#L40.


Describe the solution you'd like

  • I would like the plugin to run on the vite command (development server) as well as vite build

Describe alternatives you've considered

  • I currently have environment specific code which ensures the shadow dom is only used in production. But it is not ideal to have two different code paths.

Additional context

@marco-prontera
Copy link
Owner

Hi, I'll check if it's possible this week. Thank you for opening the issue

@marco-prontera
Copy link
Owner

@bytestream Could you give me a sample repository so I can do some testing directly?

@htuomola
Copy link

@bytestream so did you get it working in build step & shadow dom - injecting styles to the shadow root? Did you have to do anything special for that? I'm trying to achieve the same thing.

@bytestream
Copy link
Author

@marco-prontera sure, see https://github.com/bytestream/vite-plugin-css-injected-by-js-demo

@felixpaq
Copy link

Good morning @marco-prontera! Did you have the chance to take a look into this?

@marco-prontera
Copy link
Owner

Hi @felixpaq, I'm working on it ;)

@marco-prontera marco-prontera self-assigned this Jan 15, 2024
@marco-prontera marco-prontera added the enhancement New feature or request label Jan 15, 2024
@marco-prontera
Copy link
Owner

marco-prontera commented Jan 15, 2024

Hi the v3.4.0-beta.0 that contains the code to support dev server is live, to use the plugin also in dev mode you need to configure some params: https://github.com/marco-prontera/vite-plugin-css-injected-by-js/tree/v3.4.0-beta.0?tab=readme-ov-file#dev-object

Note:
The dev environment isn't equally to the build phase. What happen in the dev environment can't be the same as in the build phase, so for that reason some parameter can't be used and some others doesn't make sense to run in the dev environment.
The injectCode or the injectCodeFunction are called multiple times in the dev environment since in dev it can't "bundle" the whole css code as in the build phase.

If some of you have a solution you can open a PR or share the information.

I'd love to hear your feedback, thanks guys!

@marco-prontera
Copy link
Owner

@bytestream have you tried?

@bytestream
Copy link
Author

bytestream commented Jan 22, 2024

@marco-prontera it works a treat 👀 Thanks very much for your efforts!

marco-prontera added a commit that referenced this issue Jan 28, 2024
* feat: implement dev mode

fix: just add where needed

docs: update

* 3.4.0-beta.0

* 3.4.0
@marco-prontera
Copy link
Owner

Available in v3.4.0, thank you!

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

No branches or pull requests

4 participants