nystudio107 / craft-vite

Allows the use of the Vite.js next generation frontend tooling with Craft CMS
MIT License
52 stars 16 forks source link

`checkDevServer` config setting not working as expected when using Vite 3 #37

Closed kylecotter closed 2 years ago

kylecotter commented 2 years ago

Describe the bug

The checkDevServer config setting when set to true is not having the desired effect when using it with Vite 3. Currently, when running the Vite dev server, this config setting needs to be false or not set for any assets to generate.

Similar comment here but splitting out into its own ticket.

To reproduce

Steps to reproduce the behaviour:

  1. Set checkDevServer to true in config/vite.php
  2. Run vite command
  3. In browser, no js/css assets are injected

Expected behaviour

Previous functionality with Vite 2 exists where you can set the checkDevServer setting and have the Vite Craft plugin determine whether to inject assets or read from a manifest file based on the dev server running or not.

Versions

Thanks!

khalwat commented 2 years ago

On vacation at the moment, so have done nothing to vette this with Vite 3 yet.

Let me know if you find any info on how they are recommending you check for the devServer running in Vite 3.

jalendport commented 2 years ago

Looked into this briefly because I'd love to move to Vite 3 soon-ish, but will probably wait until a couple point releases come out and things are more settled 😅

Anyway, I didn't find a solution, but here are some PRs for future reference that had a direct bearing on the change:

khalwat commented 2 years ago

Looks like this might be the way: https://github.com/vitejs/vite/pull/6819/files

So just try the raw dev server, and if I get a 400 it's running, and if it just can't connect at all, it isn't.

khalwat commented 2 years ago

Addressed in:

Craft 3: Version 1.0.27 -> https://github.com/nystudio107/craft-vite/releases/tag/1.0.27

Craft 4: Version 4.0.2 -> https://github.com/nystudio107/craft-vite/releases/tag/4.0.2