Closed acalvino4 closed 2 years ago
This is not an issue with the Craft Vite plugin.
I'd suggest looking at existing setups that work, here are two:
DDEV: https://github.com/onedarnleyroad/craftcms
Docker: https://github.com/nystudio107/craft
Also a course on DDEV from CraftQuest.io: https://craftquest.io/courses/ddev-and-craft-cms-quick-start-guide
I figured it probably wasn't an issue with this plugin, which is why I opened it as a question rather than bug. I was just curious if anything might have jumped out to someone experienced as being out of line, especially regarding where the bad gateway is coming from or why {{ craft.vite.devServerRunning() }}
was returning false.
In the meantime I'll keep digging into the documentation.
Yeah sorry, I don't use DDEV so I can't really help you with some of the DDEV particular issues, other than point you at example setups that work.
If I had to guess, it'd be that a port hasn't been opened on the DDEV end of things or such.
For anyone who comes across this later....
I did get it working by following the CraftQuest video, though I don't know which config was specifically the problem. Here are the changes I made:
vite.config.js
, I removed the mkcert vite plugin, and added viteCompress and manifestSRI plugins.vite.config.js
, I removed https: true,
from my server
configvite.config.js
to vite.config.ts
, and used the defineConfig
helper function rather than exporting my config without itvite.php
, I defined and used Craft::getAlias('@web')
instead of App::env('PRIMARY_SITE_URL')
vite.php
, I made 'checkDevServer' => true,
@acalvino4 are you running Vite 3 ? Since I upgraded to vite 3 I have the exact same issue
@khalwat 'checkDevServer' => true
seems that this option is broken after upgrading to vite 3
@kevinmu17 please see this ticket: https://github.com/nystudio107/craft-vite/issues/37
Question
I have spent hours pouring over all the documentation I can find, tweaking parameters, but cannot seem to get my Vite server running within my DDEV environment.
I have successfully run
npm run dev
/vite
both on local and within my container. However, any url of the form127.0.0.1:3000/...
returns a 502, as doescraft.ddev.site:3000/...
. This happens whether I load the url manually or through twig:{{ craft.vite.script("src/ts/index.ts") }}
. The markup generated by this tag seems to be correct:<script type="module" src="https://craft.ddev.site:3000/src/ts/index.ts"></script>
Also, I have confirmed through
{{ craft.vite.devServerRunning() }}
that the dev server is running, though if i make'checkDevServer' => true,
, the devServerRunning tag says that it's not. So not sure what to make of that. Anyway, below are my configs - let me know if something seems off, and Thanks!vite.php
vite.config.js
docker-compose.vite.yaml
src/ts/index.ts