2024-10-02
This commit is contained in:
parent
11960f633a
commit
93a452ec4a
42 changed files with 895 additions and 207 deletions
49
.ddev/commands/web/vite
Executable file
49
.ddev/commands/web/vite
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
|
||||
#ddev-generated
|
||||
|
||||
## Description: Run vite inside the web container. Servers started by vite (dev, preview) are proxied and made available at https://vite.$PROJECTNAME.ddev.site
|
||||
## Usage: vite dev|serve|build|optimize|preview [flags] [args]
|
||||
## Example: "ddev vite" or "ddev vite build" or "ddev vite build --outDir path/to/output/"
|
||||
## ExecRaw: true
|
||||
## HostWorkingDir: true
|
||||
## AutocompleteTerms: ["dev","serve","build","optimize","preview"]
|
||||
|
||||
# Preferred package manager can be specified via VITE_PACKAGE_MANAGER environment variable in config.vite.yaml
|
||||
PACKAGE_MANAGER="${VITE_PACKAGE_MANAGER:-npm}"
|
||||
|
||||
COMMAND="${1:-dev}"
|
||||
OPTIONS=$@
|
||||
|
||||
case $PACKAGE_MANAGER in
|
||||
npm | npx)
|
||||
PACKAGE_MANAGER_COMMAND="npx vite"
|
||||
;;
|
||||
yarn)
|
||||
PACKAGE_MANAGER_COMMAND="yarn exec vite --"
|
||||
;;
|
||||
pnpm)
|
||||
PACKAGE_MANAGER_COMMAND="pnpm exec vite"
|
||||
;;
|
||||
bun)
|
||||
PACKAGE_MANAGER_COMMAND="bun vite"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid node package manager specified: $PACKAGE_MANAGER"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "${COMMAND:0:1}" == "-" ]]; then
|
||||
COMMAND="dev"
|
||||
else
|
||||
OPTIONS="${@:2}"
|
||||
fi
|
||||
|
||||
echo "Using $PACKAGE_MANAGER to run vite..."
|
||||
|
||||
if [[ $COMMAND == "dev" ]] || [[ $COMMAND == "serve" ]] || [[ $COMMAND == "preview" ]]; then
|
||||
$PACKAGE_MANAGER_COMMAND $COMMAND --host --port 5173 --strictPort $OPTIONS
|
||||
else
|
||||
$PACKAGE_MANAGER_COMMAND $COMMAND $OPTIONS
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue