feat: Vite compat DDEV
This commit is contained in:
parent
867e7993bb
commit
d2533e326d
5 changed files with 1574 additions and 2047 deletions
14
inc/vite.php
14
inc/vite.php
|
@ -2,6 +2,7 @@
|
||||||
if (!defined("_ECRIRE_INC_VERSION")) {
|
if (!defined("_ECRIRE_INC_VERSION")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
defined('_SERVEUR_MODE') || define('_SERVEUR_MODE', 'PROD');
|
||||||
|
|
||||||
// Helpers here serve as example. Change to suit your needs.
|
// Helpers here serve as example. Change to suit your needs.
|
||||||
// const VITE_HOST = "https://localhost:5134";
|
// const VITE_HOST = "https://localhost:5134";
|
||||||
|
@ -16,7 +17,12 @@ if (!defined("_ECRIRE_INC_VERSION")) {
|
||||||
// Prints all the html entries needed for Vite
|
// Prints all the html entries needed for Vite
|
||||||
|
|
||||||
function vite(string $entry, $port = "5134"): string {
|
function vite(string $entry, $port = "5134"): string {
|
||||||
defined('VITE_HOST') || define('VITE_HOST', "https://localhost:".$port);
|
if ($_SERVER['IS_DDEV_PROJECT'] ) {
|
||||||
|
defined('VITE_HOST') || define('VITE_HOST', "https://" . $_SERVER['SERVER_ADDR'] . ":" .$port);
|
||||||
|
} else {
|
||||||
|
defined('VITE_HOST') || define('VITE_HOST', "https://localhost:".$port);
|
||||||
|
}
|
||||||
|
|
||||||
return "\n" .
|
return "\n" .
|
||||||
jsTag($entry) .
|
jsTag($entry) .
|
||||||
"\n" .
|
"\n" .
|
||||||
|
@ -38,12 +44,8 @@ function isDev(string $entry): bool {
|
||||||
return $exists;
|
return $exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if ( _SERVEUR_MODE !== 'PROD') {
|
||||||
!empty($_SERVER["SERVER_ADDR"]) and
|
|
||||||
in_array($_SERVER["SERVER_ADDR"], ["::1", "127.0.0.1"])
|
|
||||||
) {
|
|
||||||
$handle = curl_init(VITE_HOST . "/" . $entry);
|
$handle = curl_init(VITE_HOST . "/" . $entry);
|
||||||
|
|
||||||
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
|
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
|
||||||
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
|
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
|
||||||
|
|
1748
package-lock.json
generated
1748
package-lock.json
generated
File diff suppressed because it is too large
Load diff
54
package.json
54
package.json
|
@ -1,24 +1,34 @@
|
||||||
{
|
{
|
||||||
"name": "gamutable",
|
"name": "gamutable",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"type": "module",
|
||||||
"dev": "APP_ENV=development vite",
|
"scripts": {
|
||||||
"build": "vite build",
|
"dev": "vite --mode dev",
|
||||||
"watch": "vite build --watch",
|
"build": "vite build --mode prod",
|
||||||
"preview": "vite preview"
|
"watch": "vite build --watch --mode prod"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vitejs/plugin-basic-ssl": "^1.0.1",
|
"@vueform/multiselect": "^2.6.6",
|
||||||
"typescript": "^5.1.6",
|
"jenesius-vue-modal": "^1.11.0",
|
||||||
"vue": "^3.2.47",
|
"json5": "^2.2.3",
|
||||||
"vue-next-select": "^2.10.5",
|
"luxon": "^3.4.4",
|
||||||
"vue-papa-parse": "^3.1.0"
|
"typescript": "^5.3.3",
|
||||||
},
|
"vue": "^3.4.21",
|
||||||
"devDependencies": {
|
"vue-cookie-next": "^1.3.0",
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
"vue-next-select": "^2.10.5",
|
||||||
"@vue/compiler-sfc": "^3.2.47",
|
"vue-papa-parse": "^3.1.0",
|
||||||
"vite": "^4.1.1",
|
"vue3-selecto": "^1.12.3"
|
||||||
"vite-plugin-live-reload": "^3.0.1"
|
},
|
||||||
}
|
"devDependencies": {
|
||||||
|
"@types/jquery": "^3.5.29",
|
||||||
|
"@types/luxon": "^3.4.2",
|
||||||
|
"@vitejs/plugin-vue": "^5.0.4",
|
||||||
|
"@vue/compiler-sfc": "^3.4.21",
|
||||||
|
"eslint": "^8.57.0",
|
||||||
|
"eslint-plugin-vue": "^9.22.0",
|
||||||
|
"vite": "^5.1.4",
|
||||||
|
"vite-plugin-live-reload": "^3.0.3",
|
||||||
|
"vite-plugin-mkcert": "^1.17.4"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
1714
pnpm-lock.yaml
generated
1714
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -1,55 +1,60 @@
|
||||||
import { defineConfig, splitVendorChunkPlugin } from "vite";
|
// import { defineConfig, splitVendorChunkPlugin } from "vite";
|
||||||
|
import { defineConfig } from "vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import liveReload from "vite-plugin-live-reload";
|
import liveReload from "vite-plugin-live-reload";
|
||||||
import path from "path";
|
import path, { dirname } from "path";
|
||||||
import fs from "fs";
|
// import fs from "fs";
|
||||||
import basicSsl from "@vitejs/plugin-basic-ssl";
|
import mkcert from 'vite-plugin-mkcert'
|
||||||
|
import { fileURLToPath } from 'url'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig(({ mode }) => {
|
||||||
plugins: [
|
const __filename = fileURLToPath(import.meta.url)
|
||||||
vue({
|
const __dirname = dirname(__filename)
|
||||||
template: {
|
const port = 5134
|
||||||
transformAssetUrls: {
|
return {
|
||||||
base: "plugins/gamutable",
|
root: "src",
|
||||||
includeAbsolute: false,
|
base: mode === "dev" ? "/" : "/dist/",
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
vue({
|
||||||
|
template: {
|
||||||
|
transformAssetUrls: {
|
||||||
|
base: "plugins/gamutable",
|
||||||
|
includeAbsolute: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
}),
|
||||||
|
liveReload([__dirname + "/**/*.php", __dirname + "/**/*.html"]),
|
||||||
|
// splitVendorChunkPlugin(),
|
||||||
|
mkcert()
|
||||||
|
],
|
||||||
|
|
||||||
|
// config
|
||||||
|
|
||||||
|
build: {
|
||||||
|
outDir: "../dist",
|
||||||
|
emptyOutDir: true,
|
||||||
|
manifest: true,
|
||||||
|
// cssCodeSplit: false,
|
||||||
|
|
||||||
|
rollupOptions: {
|
||||||
|
input: path.resolve(__dirname, "src/gamutable.js"),
|
||||||
},
|
},
|
||||||
}),
|
|
||||||
liveReload([__dirname + "/**/*.php", __dirname + "/**/*.html"]),
|
|
||||||
splitVendorChunkPlugin(),
|
|
||||||
// basicSsl(),
|
|
||||||
],
|
|
||||||
|
|
||||||
// config
|
|
||||||
root: "src",
|
|
||||||
base: process.env.APP_ENV === "development" ? "/" : "/dist/",
|
|
||||||
|
|
||||||
build: {
|
|
||||||
outDir: "../dist",
|
|
||||||
emptyOutDir: true,
|
|
||||||
manifest: true,
|
|
||||||
|
|
||||||
rollupOptions: {
|
|
||||||
input: path.resolve(__dirname, "src/gamutable.js"),
|
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
|
||||||
server: {
|
server: {
|
||||||
strictPort: true,
|
host: true,
|
||||||
port: 5134,
|
port: port,
|
||||||
https: {
|
strictPort: true,
|
||||||
key: fs.readFileSync("certs/vite.key.pem"),
|
|
||||||
cert: fs.readFileSync("certs/vite.crt.pem"),
|
|
||||||
},
|
},
|
||||||
cors: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
// required for in-browser template compilation
|
// required for in-browser template compilation
|
||||||
// https://vuejs.org/guide/scaling-up/tooling.html#note-on-in-browser-template-compilation
|
// https://vuejs.org/guide/scaling-up/tooling.html#note-on-in-browser-template-compilation
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
vue: "vue/dist/vue.esm-bundler.js",
|
vue: "vue/dist/vue.esm-bundler.js",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue