source map, vite hmr dev server dynimic port
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
var _l=Object.defineProperty;var ml=(o,e,i)=>e in o?_l(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i;var G=(o,e,i)=>ml(o,typeof e!="symbol"?e+"":e,i);(function(){try{var o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new o.Error().stack;e&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[e]="bbcb9b46-522a-40c8-ad0c-a976530c2700",o._sentryDebugIdIdentifier="sentry-dbid-bbcb9b46-522a-40c8-ad0c-a976530c2700")}catch{}})();function mi(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function $o(o,e){o.prototype=Object.create(e.prototype),o.prototype.constructor=o,o.__proto__=e}/*!
|
||||
var _l=Object.defineProperty;var ml=(o,e,i)=>e in o?_l(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i;var G=(o,e,i)=>ml(o,typeof e!="symbol"?e+"":e,i);function mi(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function $o(o,e){o.prototype=Object.create(e.prototype),o.prototype.constructor=o,o.__proto__=e}/*!
|
||||
* GSAP 3.15.0
|
||||
* https://gsap.com
|
||||
*
|
||||
|
||||
+2
-2
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
@@ -30,14 +30,6 @@ titles:
|
||||
type: module
|
||||
defer: true
|
||||
|
||||
titles_hmr:
|
||||
header: true
|
||||
js:
|
||||
https://localhost:5173/assets/js/titles.js:
|
||||
type: external
|
||||
attributes:
|
||||
type: module
|
||||
|
||||
# Glitchtip (Sentry front) : init au plus tôt, dans le head, avant main.js
|
||||
# (voir assets/js/sentry.js).
|
||||
sentry:
|
||||
@@ -48,21 +40,9 @@ sentry:
|
||||
type: module
|
||||
defer: true
|
||||
|
||||
sentry_hmr:
|
||||
header: true
|
||||
js:
|
||||
https://localhost:5173/assets/js/sentry.js:
|
||||
type: external
|
||||
attributes:
|
||||
type: module
|
||||
|
||||
vitehmr:
|
||||
js:
|
||||
https://localhost:5173/@vite/client:
|
||||
type: external
|
||||
attributes:
|
||||
type: module
|
||||
https://localhost:5173/assets/js/main.js:
|
||||
type: external
|
||||
attributes:
|
||||
type: module
|
||||
# En dev, les scripts du dev server Vite (@vite/client + sentry.js +
|
||||
# titles.js + main.js) ne sont PAS dans une librairie statique : le port est
|
||||
# dynamique (premier port libre à partir de 5173, voir le plugin
|
||||
# dev-port-file dans vite.config.js / .vite-dev-port), donc
|
||||
# leshed_page_attachments_alter() les attache
|
||||
# directement en html_head.
|
||||
|
||||
@@ -7,18 +7,33 @@
|
||||
|
||||
function leshed_page_attachments_alter(&$page) {
|
||||
if (getenv('APP_ENV') === 'development') {
|
||||
// $attachments['#attached']['html_head'][] = [['src' => 'http://localhost:5173/@vite/client', 'type' => 'module'],'vite-client'];
|
||||
// $page['#attached']['library'][] = 'http://localhost:5173/@vite/client';
|
||||
// $attachments['#attached']['html_head'][] = [['src' => 'http://localhost:5173/assets/js/main.js', 'type' => 'module'],'vite-main'];
|
||||
// $page['#attached']['library'][] = 'http://localhost:5173/assets/js/main.js';
|
||||
$page['#attached']['library'][] = 'leshed/sentry_hmr';
|
||||
$page['#attached']['library'][] = 'leshed/vitehmr';
|
||||
$page['#attached']['library'][] = 'leshed/titles_hmr';
|
||||
// Port réel du dev server Vite, écrit par le plugin devPortFilePlugin
|
||||
// (vite.config.js) dans .vite-dev-port
|
||||
// (premier port libre à partir de 5173, strictPort: false) : permet de
|
||||
// lancer plusieurs sites sur le même modèle de thème en même temps.
|
||||
$port = (int) trim((string) @file_get_contents(__DIR__ . '/.vite-dev-port'));
|
||||
if ($port <= 0) {
|
||||
$port = 5173;
|
||||
}
|
||||
// Scripts du dev server, attachés directement en html_head (pas de
|
||||
// librairie statique : le port est dynamique). Ordre : @vite/client,
|
||||
// sentry.js (Glitchtip, avant tout pour capturer tôt), titles.js, main.js.
|
||||
foreach (['@vite/client', 'assets/js/sentry.js', 'assets/js/titles.js', 'assets/js/main.js'] as $i => $path) {
|
||||
$page['#attached']['html_head'][] = [
|
||||
[
|
||||
'#type' => 'html_tag',
|
||||
'#tag' => 'script',
|
||||
'#attributes' => ['type' => 'module', 'src' => "https://localhost:{$port}/{$path}"],
|
||||
],
|
||||
'vite-dev-' . $i,
|
||||
];
|
||||
}
|
||||
// CSS compilée en <link> render-blocking : sans elle, la page se peint
|
||||
// sans styles pendant le chargement des modules Vite (qui portent la CSS
|
||||
// en dev). Le build --watch tient assets/dist/main.css frais ; les styles
|
||||
// injectés ensuite par Vite, plus tardifs dans la cascade, prennent le
|
||||
// dessus sur les égalités.
|
||||
// en dev). Le build watch lancé par le plugin dev-port-file tient
|
||||
// assets/dist/main.css frais ;
|
||||
// les styles injectés ensuite par Vite, plus tardifs dans la cascade,
|
||||
// prennent le dessus sur les égalités.
|
||||
$page['#attached']['library'][] = 'leshed/base_css';
|
||||
}else{
|
||||
$page['#attached']['library'][] = 'leshed/sentry';
|
||||
|
||||
-263
@@ -20,7 +20,6 @@
|
||||
"devDependencies": {
|
||||
"@sentry/vite-plugin": "^11.20.0",
|
||||
"@vitejs/plugin-vue": "^5.0.5",
|
||||
"concurrently": "^10.0.5",
|
||||
"sass": "^1.77.8",
|
||||
"vite": "^5.3.1"
|
||||
}
|
||||
@@ -1815,32 +1814,6 @@
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-regex": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.3.0.tgz",
|
||||
"integrity": "sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-regex?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-styles": {
|
||||
"version": "6.2.3",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz",
|
||||
"integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
@@ -1895,19 +1868,6 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "5.6.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz",
|
||||
"integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/chokidar": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz",
|
||||
@@ -1924,21 +1884,6 @@
|
||||
"url": "https://paulmillr.com/funding/"
|
||||
}
|
||||
},
|
||||
"node_modules/cliui": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz",
|
||||
"integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"string-width": "^7.2.0",
|
||||
"strip-ansi": "^7.1.0",
|
||||
"wrap-ansi": "^9.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
@@ -1951,31 +1896,6 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/concurrently": {
|
||||
"version": "10.0.5",
|
||||
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-10.0.5.tgz",
|
||||
"integrity": "sha512-JaP/CoftUrCcAFW/g//RbgEGwlelnEae6cfBLgH6ZdO6s8jPkn6p9SB9u6pdVxYXoiSnFqseOlHfrEfF82TVOg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"chalk": "5.6.2",
|
||||
"rxjs": "7.8.2",
|
||||
"shell-quote": "1.9.0",
|
||||
"supports-color": "10.2.2",
|
||||
"tree-kill": "1.2.2",
|
||||
"yargs": "18.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"conc": "dist/bin/index.js",
|
||||
"concurrently": "dist/bin/index.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/open-cli-tools/concurrently?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/csstype": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||
@@ -2046,13 +1966,6 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "10.6.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
|
||||
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
|
||||
@@ -2149,16 +2062,6 @@
|
||||
"@esbuild/win32-x64": "0.21.5"
|
||||
}
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
|
||||
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/estree-walker": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||
@@ -2231,29 +2134,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-caller-file": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "6.* || 8.* || >= 10.*"
|
||||
}
|
||||
},
|
||||
"node_modules/get-east-asian-width": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz",
|
||||
"integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
@@ -2726,16 +2606,6 @@
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/rxjs": {
|
||||
"version": "7.8.2",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz",
|
||||
"integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"tslib": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/sass": {
|
||||
"version": "1.101.0",
|
||||
"resolved": "https://registry.npmjs.org/sass/-/sass-1.101.0.tgz",
|
||||
@@ -2770,19 +2640,6 @@
|
||||
"node": ">=20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/shell-quote": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.9.0.tgz",
|
||||
"integrity": "sha512-Iov+JwFv/2HcTpcwNMKd8+IWNb8tboQJNQTkAY/LLVK7gGH9jy+LGkVqPxfekHl+yMmiqXszdGWXgkfml7hjqA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
@@ -2798,70 +2655,6 @@
|
||||
"integrity": "sha512-6Tj+4mvlSti4DUu1yl0PnkHIIoLchFYJHqz2DnwYkvEehXbjrR2epa4ds/xdto6ZdZsC+NP5IOOehi9VGjNlMQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
|
||||
"integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^10.3.0",
|
||||
"get-east-asian-width": "^1.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/strip-ansi": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz",
|
||||
"integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^6.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/supports-color": {
|
||||
"version": "10.2.2",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz",
|
||||
"integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/supports-color?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/tree-kill": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
|
||||
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"tree-kill": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"dev": true,
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "5.4.21",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz",
|
||||
@@ -2948,62 +2741,6 @@
|
||||
"resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-6.2.3.tgz",
|
||||
"integrity": "sha512-Dmy+vdO1UPMqXiAtZSNayhl4f794Bxfd94W4HIj2HlYtczEQfEOon969memlcpcHrTuOKLa5baFjX7WbgmOq+A==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/wrap-ansi": {
|
||||
"version": "9.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz",
|
||||
"integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^6.2.1",
|
||||
"string-width": "^7.0.0",
|
||||
"strip-ansi": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/y18n": {
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs": {
|
||||
"version": "18.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-18.0.0.tgz",
|
||||
"integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cliui": "^9.0.1",
|
||||
"escalade": "^3.1.1",
|
||||
"get-caller-file": "^2.0.5",
|
||||
"string-width": "^7.2.0",
|
||||
"y18n": "^5.0.5",
|
||||
"yargs-parser": "^22.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||
}
|
||||
},
|
||||
"node_modules/yargs-parser": {
|
||||
"version": "22.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz",
|
||||
"integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=23"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "concurrently -k -n hmr,build -c cyan,magenta \"vite\" \"vite build --watch\"",
|
||||
"dev:server": "vite",
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
@@ -22,7 +21,6 @@
|
||||
"devDependencies": {
|
||||
"@sentry/vite-plugin": "^11.20.0",
|
||||
"@vitejs/plugin-vue": "^5.0.5",
|
||||
"concurrently": "^10.0.5",
|
||||
"sass": "^1.77.8",
|
||||
"vite": "^5.3.1"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { defineConfig, build } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { sentryVitePlugin } from '@sentry/vite-plugin'
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { readFileSync, writeFileSync, unlinkSync } from 'node:fs'
|
||||
import { execSync } from 'node:child_process'
|
||||
|
||||
// Certificat mkcert wildcard du reverse-proxy (SAN: localhost, 127.0.0.1,
|
||||
@@ -11,6 +11,46 @@ import { execSync } from 'node:child_process'
|
||||
const TLS_CERT = fileURLToPath(new URL('../../../../../../reverse-proxy/certs/wildcard.localhost.pem', import.meta.url))
|
||||
const TLS_KEY = fileURLToPath(new URL('../../../../../../reverse-proxy/certs/wildcard.localhost-key.pem', import.meta.url))
|
||||
|
||||
// En dev uniquement : écrit le port réellement écouté par le dev server
|
||||
// dans .vite-dev-port (leshed.theme lit ce fichier pour charger le bon
|
||||
// @vite/client). Avec strictPort: false, Vite prend le premier port libre
|
||||
// à partir de 5173 : plusieurs sites sur le même modèle de thème peuvent
|
||||
// tourner `npm run dev` en même temps. Le client HMR se connecte ensuite
|
||||
// sur importMetaUrl (host:port du <script> chargé), donc automatiquement
|
||||
// sur le bon port. Le plugin lance aussi le build watch (assets/dist en
|
||||
// continu), donc `npm run dev` reste un simple `vite`.
|
||||
function devPortFilePlugin() {
|
||||
const portFile = fileURLToPath(new URL('./.vite-dev-port', import.meta.url))
|
||||
return {
|
||||
name: 'dev-port-file',
|
||||
apply: 'serve',
|
||||
async configureServer(server) {
|
||||
// Build watch : écrit les fichiers dist sur disque en continu.
|
||||
// configureServer est rappelé à chaque redémarrage interne de Vite
|
||||
// (modif de vite.config.js, touche r) : le watcher est fermé à la
|
||||
// fermeture du serveur pour ne pas en accumuler plusieurs.
|
||||
const watcherP = build({ build: { watch: {} } })
|
||||
watcherP.catch((e) => server.config.logger.error(e))
|
||||
// Supprime un éventuel fichier résiduel d'un arrêt brutal (kill -9)
|
||||
try { unlinkSync(portFile) } catch {}
|
||||
server.httpServer?.once('listening', () => {
|
||||
const address = server.httpServer.address()
|
||||
const port = typeof address === 'object' && address !== null ? address.port : server.config.server.port
|
||||
// origin = serveur réel : Vite l'utilise à chaque transform pour les
|
||||
// URLs d'assets (url() relatives des SCSS, polices, import d'images).
|
||||
// Sans elle, ces URLs sont racine-relatives (/assets/...) et, injectées
|
||||
// dans la page Drupal, résolues sur le vhost Drupal au lieu de Vite.
|
||||
server.config.server.origin = `https://localhost:${port}`
|
||||
writeFileSync(portFile, String(port))
|
||||
})
|
||||
server.httpServer?.once('close', () => {
|
||||
watcherP.then((w) => w.close()).catch(() => {})
|
||||
try { unlinkSync(portFile) } catch {}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
// Upload des sourcemaps vers Glitchtip à la fin du build (prod uniquement —
|
||||
// inactif sur le dev server). Le token n'est JAMAIS écrit en dur dans ce
|
||||
@@ -49,7 +89,7 @@ const glitchtipSourcemaps =
|
||||
: null
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue(), ...(glitchtipSourcemaps ? [glitchtipSourcemaps] : [])],
|
||||
plugins: [vue(), devPortFilePlugin(), ...(glitchtipSourcemaps ? [glitchtipSourcemaps] : [])],
|
||||
define: {
|
||||
// Release exposée au bundle (lu dans assets/js/sentry.js).
|
||||
'import.meta.env.VITE_SENTRY_RELEASE': JSON.stringify(gitSha),
|
||||
@@ -60,6 +100,10 @@ export default defineConfig({
|
||||
pure: ['console.log'],
|
||||
},
|
||||
css: {
|
||||
// Sourcemaps des styles injectés en dev (balises <style data-vite-dev-id>)
|
||||
// : l'inspecteur Firefox résout alors les règles vers les fichiers .scss
|
||||
// sources (ex. _node_full.scss) au lieu d'afficher « inline ».
|
||||
devSourcemap: true,
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
// Fait taire le DEPRECATION WARNING [legacy-js-api] de Vite : la
|
||||
@@ -76,8 +120,12 @@ export default defineConfig({
|
||||
server: {
|
||||
// The dev server must be reachable from the browser on the host.
|
||||
host: 'localhost',
|
||||
// Premier port libre à partir de 5173 : plusieurs sites sur le même
|
||||
// modèle de thème peuvent tourner `npm run dev` en même temps
|
||||
// (5173, 5174, ...). Le plugin devPortFilePlugin écrit le port choisi
|
||||
// dans .vite-dev-port pour que le thème Drupal charge le bon client.
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
strictPort: false,
|
||||
// HTTPS obligatoire depuis la migration Traefik : la page Drupal est
|
||||
// servie en https://leshed.localhost, un dev server en http://localhost:5173
|
||||
// serait bloqué en mixed content (assets + WebSocket HMR). On réutilise
|
||||
@@ -98,12 +146,13 @@ export default defineConfig({
|
||||
cors: {
|
||||
origin: [/^https:\/\/leshed\.localhost(:\d+)?$/, /^https:\/\/dev\.leshed\.fr(:\d+)?$/],
|
||||
},
|
||||
// Absolute base URL used by Vite to build asset/HMR URLs.
|
||||
origin: 'https://localhost:5173',
|
||||
// Pas d'origin ni de clientPort en dur : le WebSocket HMR se connecte sur
|
||||
// le port de l'URL du @vite/client chargé par la page (importMetaUrl), et
|
||||
// origin est fixée au port réel par devPortFilePlugin une fois le serveur
|
||||
// à l'écoute.
|
||||
hmr: {
|
||||
host: 'localhost',
|
||||
protocol: 'wss',
|
||||
clientPort: 5173,
|
||||
},
|
||||
watch: {
|
||||
usePolling: true,
|
||||
|
||||
Reference in New Issue
Block a user