2024-10-02
This commit is contained in:
parent
11960f633a
commit
93a452ec4a
42 changed files with 895 additions and 207 deletions
13
.ddev/addon-metadata/ddev-vite-sidecar/manifest.yaml
Normal file
13
.ddev/addon-metadata/ddev-vite-sidecar/manifest.yaml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
name: ddev-vite-sidecar
|
||||
repository: s2b/ddev-vite-sidecar
|
||||
version: 1.1.0
|
||||
install_date: "2024-10-02T19:02:43+02:00"
|
||||
project_files:
|
||||
- commands/web/vite
|
||||
- apache/vite.conf
|
||||
- nginx_full/vite.conf
|
||||
- vite/vite-server-not-running.html
|
||||
- config.vite.yaml
|
||||
- web-build/Dockerfile.vite
|
||||
global_files: []
|
||||
removal_actions: []
|
||||
30
.ddev/apache/vite.conf
Normal file
30
.ddev/apache/vite.conf
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#ddev-generated
|
||||
<VirtualHost *:80>
|
||||
ServerName vite.haikuatelier.fr.ddev.site
|
||||
DocumentRoot /mnt/ddev_config/vite/
|
||||
ErrorDocument 503 "/vite-server-not-running.html"
|
||||
|
||||
# Proxy development server
|
||||
ProxyPass / http://localhost:5173/
|
||||
ProxyPassReverse / http://localhost:5173/
|
||||
|
||||
# Proxy websockets
|
||||
RewriteEngine On
|
||||
RewriteCond %{HTTP:Upgrade} websocket [NC]
|
||||
RewriteCond %{HTTP:Connection} upgrade [NC]
|
||||
RewriteRule ^/?(.*) "ws://localhost:5173/$1" [P,L]
|
||||
|
||||
# Do not proxy files in /vite to display the static 503 error message
|
||||
<Location "/vite-server-not-running.html">
|
||||
ProxyPass !
|
||||
</Location>
|
||||
|
||||
<Directory "/mnt/ddev_config/vite/">
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
ErrorLog /dev/stdout
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
|
||||
Alias "/phpstatus" "/var/www/phpstatus.php"
|
||||
</VirtualHost>
|
||||
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
|
||||
16
.ddev/config.vite.yaml
Normal file
16
.ddev/config.vite.yaml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#ddev-generated
|
||||
additional_hostnames:
|
||||
- vite.haikuatelier.fr
|
||||
web_environment:
|
||||
- VITE_SERVER_URI=https://vite.haikuatelier.fr.ddev.site
|
||||
- VITE_PACKAGE_MANAGER=pnpm
|
||||
|
||||
# Enable these lines if you want to expose the vite port to the host system
|
||||
# Note that this means that only one ddev project with vite can be run at a time
|
||||
# as the different processes might interfere with each other
|
||||
#
|
||||
# web_extra_exposed_ports:
|
||||
# - name: vite
|
||||
# container_port: 5173
|
||||
# http_port: 5172
|
||||
# https_port: 5173
|
||||
|
|
@ -12,7 +12,7 @@ database:
|
|||
use_dns_when_possible: true
|
||||
composer_version: "2"
|
||||
web_environment: []
|
||||
corepack_enable: false
|
||||
corepack_enable: true
|
||||
|
||||
# Key features of DDEV's config.yaml:
|
||||
|
||||
|
|
|
|||
33
.ddev/nginx_full/vite.conf
Normal file
33
.ddev/nginx_full/vite.conf
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#ddev-generated
|
||||
server {
|
||||
server_name vite.haikuatelier.fr.ddev.site;
|
||||
|
||||
listen 80;
|
||||
listen 443 ssl;
|
||||
|
||||
ssl_certificate /etc/ssl/certs/master.crt;
|
||||
ssl_certificate_key /etc/ssl/certs/master.key;
|
||||
|
||||
include /etc/nginx/monitoring.conf;
|
||||
|
||||
# Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
|
||||
sendfile off;
|
||||
error_log /dev/stdout info;
|
||||
access_log off;
|
||||
|
||||
location /vite-server-not-running.html {
|
||||
root /mnt/ddev_config/vite/;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:5173;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
||||
proxy_set_header X-Forwarded-Host $http_x_forwarded_host;
|
||||
error_page 502 /vite-server-not-running.html;
|
||||
}
|
||||
}
|
||||
49
.ddev/vite/vite-server-not-running.html
Normal file
49
.ddev/vite/vite-server-not-running.html
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- #ddev-generated -->
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>vite not running</title>
|
||||
<style>
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #DDD;
|
||||
display: grid;
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 36rem;
|
||||
background: #FFF;
|
||||
padding: 1.5rem;
|
||||
border: 1px #999 solid;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;
|
||||
font-size: 180%;
|
||||
color: #9499ff;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>vite not running</h1>
|
||||
<p>Apparently, you tried to access resources from the vite development server. However, the server is currently not running.</p>
|
||||
<p>You can start the server by running the following command in your terminal:</p>
|
||||
<code>ddev vite</code>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
2
.ddev/web-build/Dockerfile.vite
Normal file
2
.ddev/web-build/Dockerfile.vite
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#ddev-generated
|
||||
RUN a2enmod proxy_http
|
||||
Loading…
Add table
Add a link
Reference in a new issue