ddev-viteserve
ddev-viteserve copied to clipboard
[feat] Make the add-on "Laravel-aware"
I'm experimenting with making the add-on change its behavior when used in projects of type: laravel. Changes would include at least:
- Changing the javascript directory to ".", which seems to be the laravel default.
- Making the choice of the package manager more intelligent. New behavior will be:
- Check for a setting in
.ddev/.env - Otherwise: see if npm, yarn or pnpm has installed its lock-file and node_modules/ exists.
- Otherwise: ask the user which of these package managers to use.
This issue is the tracking issue for the PRs relevant to this issue.
You should be able to compare $DDEV_PROJECT_TYPE to laravel. That gets the Laravel users that use the project type. But there are others that use project type 'php'
You should be able to compare
$DDEV_PROJECT_TYPEtolaravel. That gets the Laravel users that use the project type. But there are others that use project type 'php'
OK, easier than munging config.yaml myself. I'll try this to see if it works where I'm doing that.
For folks like @tyler36 to try to make sure this does what it needs to do:
Here's what the UI looks like when you do not set a package manager and do not do npm install or its yarn/pnpm equivalent:
- Get the current code by doing
ddev get https://github.com/torenware/ddev-viteserve/tarball/laravel-aware-5 ddev restart- If you now call
ddev vite-serveon a completely fresh project, without modifying the generated.ddev/.envfile, you'll see something like this:
$ ddev vite-serve
1) npm
2) yarn
3) pnpm
Choose the package manager to use:
- Start by choosing "1" for npm. vite-serve will run
npm installfor you, and start vite for you.
Choose the package manager to use: 1
'npm'
Using package manager npm
added 26 packages, and audited 27 packages in 18s
6 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm notice
npm notice New minor version of npm available! 8.11.0 -> 8.19.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.19.2
npm notice Run npm install -g [email protected] to update!
npm notice
Vite now serving .
- To see the "already installed state", run
ddev vite-serve stop, and then runddev vite-serveagain:
$ ddev vite-serve stop
stopping vite
$ ddev vite-serve
'npm'
Using package manager npm
up to date, audited 27 packages in 1s
6 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Vite now serving .
- Note that vite-serve auto-detected the previous npm install, but reran
npm installto make sure things haven't changed in your package.json and lock file. - Delete node_modules/ and the lock file, and you'll be able to see the selection menu come up again when you restart vite-serve.
- Try this with yarn or pnpm to see this also works.
- Then, on a clean install of the stock Laravel project, use the procedure in the current CMS Quickstart Guide, to confirm that I haven't broken that path either.
You should be able to compare
$DDEV_PROJECT_TYPEtolaravel. That gets the Laravel users that use the project type. But there are others that use project type 'php'
This works fine, and the code is refactored accordingly. For the php type, it probably does not make sense to do this; in my own use of it, I still tend to put the vite project in a sub-directory, and there's no reason to suppose that people would mix the php and js code as has become Laravel's preference. For everybody else, laissez les bons temps rouler, non?