- Issue created by @wotnak
- π«π·France aridard
Hello,
I'm working in a docker environment with multiple projects runing at the same time, with multiple Vite server runing at the same time.
I think it is not a Drupal module problematic, you need a reverse proxy that will do routing with port binding correctly depending on network rules.I implemented https://traefik.io/ in order to expose vite server and port through custom domain names. I do not have the need to bind port on my computer directly anymore, that solves the problem.
- π΅π±Poland wotnak
Configuring domain solves the problem of binding ports directly, but it is still an additional configuration step that could be skipped by proxying requests to vite dev server. Also, when running multiple vite dev servers simultaneously inside single project (for example in a multisite setup for common base theme and specific site theme or maybe for a theme and a decoupled react based block) you would need to configure multiple domains pointing to different ports.
- πΊπΈUnited States mortona2k Seattle
I'm using lando. This will set up vite to run inside the container on port 3000 (change the port in vite.config.js). Lando sets up the node.demo.lndo.site proxy to point to the internal vite instance.
proxy: node: - node.demo.lndo.site:3000 services: node: type: node:18 ssl: true sslExpose: false port: 3000 scanner: false tooling: npm: service: node cmd: npm
This is all working, but one issue I'm facing is getting unocss devtools to work. I am loading 'virtual:unocss-devtools' in my main.js. The console says the devtools are connected, but throws an error loading https://demo.lndo.site/@unocss-devtools-update, which is the drupal url. Looks like this is the path that requests new styles when classes are changed in the inspector. This path needs to route to the vite instance instead.
It seems like any extra dependency loaded by a library will run into this issue. I tried using resolve.alias, but that didn't do it. The proposal to proxy requests from Drupal sounds like it would make things easier. Is there any workaround within the vite config?