s2b / ddev-vite-sidecar

Apache License 2.0
1 stars 1 forks source link

Would pm2 add benefits? #3

Closed mandrasch closed 1 month ago

mandrasch commented 1 month ago

Hey,

because of a support request in DDEV Discord, I briefly checked out how Andy Blum worked with pm2 in https://github.com/Lullabot/ddev-node-js-demo

The thing I personally liked about this approach is the flexibility in configuring your apps.config.js

module.exports = {
  apps : [
    {
      name: "Svelte",
      cwd: "/var/www/html/svelte",
      script: "npm run dev || (rm -rf node_modules && npm install && npm run dev)"
    },
    {
      name: "Keystone",
      cwd: "/var/www/html/keystone",
      script: "npm run dev || (rm -rf node_modules && npm install && npm run dev)"
    }
  ]
}

If vite sidecar would use it, developers could easily switch to their preferred package manager and preferred start command?

module.exports = {
  apps : [
    {
      name: "Vite",
      cwd: "/var/www/html/",
      script: "npm run dev"
    }
  ]
}

There is also ddev pm2 logs and a start / stop / kill option.

image

image

The downside is - of course - a bit more technical complexity. 🤔

And developers would have to change their vite.config.js as well to respond to all network requests, etc. - since this is not covered by the plugin anymore.

Btw: I'm currently thinking generally about what would be the easiest, but most configurable / flexible way of providing a Vite plugin for DDEV users with PHP projects.

I guess the current philosophy / goal of your plugin is "install the plugin, Vite just works"?

s2b commented 1 month ago

I get your point why this would be interesting. However, I try to keep this as simple as possible, which is why I try to get away with just letting vite run in the foreground. At least from my personal experience, I find the feedback from vite dev server helpful during development, which is why I would prefer for it to run in the foreground anyways.

Maybe I should add a clear disclaimer to the project's readme about the narrow focus of this project: To have a single (!) vite server running alongside your main project in ddev (written in php or whatever), without leaking its port to the host system.