mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 17:59:28 +08:00
pass hub version through html and update dependencies
- Changed Vite configuration to replace version during development.
This commit is contained in:
@@ -172,6 +172,7 @@ func (h *Hub) startServer(se *core.ServeEvent) error {
|
|||||||
basePath := strings.TrimSuffix(parsedURL.Path, "/") + "/"
|
basePath := strings.TrimSuffix(parsedURL.Path, "/") + "/"
|
||||||
indexFile, _ := fs.ReadFile(site.DistDirFS, "index.html")
|
indexFile, _ := fs.ReadFile(site.DistDirFS, "index.html")
|
||||||
indexContent := strings.ReplaceAll(string(indexFile), "./", basePath)
|
indexContent := strings.ReplaceAll(string(indexFile), "./", basePath)
|
||||||
|
indexContent = strings.Replace(indexContent, "{{V}}", beszel.Version, 1)
|
||||||
// set up static asset serving
|
// set up static asset serving
|
||||||
staticPaths := [2]string{"/static/", "/assets/"}
|
staticPaths := [2]string{"/static/", "/assets/"}
|
||||||
serveStatic := apis.Static(site.DistDirFS, false)
|
serveStatic := apis.Static(site.DistDirFS, false)
|
||||||
|
Binary file not shown.
@@ -6,7 +6,12 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="./static/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="./static/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Beszel</title>
|
<title>Beszel</title>
|
||||||
<script>window.BASE_PATH = "%BASE_URL%"</script>
|
<script>
|
||||||
|
globalThis.BESZEL = {
|
||||||
|
BASE_PATH: "%BASE_URL%",
|
||||||
|
HUB_VERSION: "{{V}}"
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
486
beszel/site/package-lock.json
generated
486
beszel/site/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "beszel",
|
"name": "beszel",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.0",
|
"version": "0.10.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -12,9 +12,10 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@henrygd/queue": "^1.0.7",
|
"@henrygd/queue": "^1.0.7",
|
||||||
"@lingui/detect-locale": "^4.14.1",
|
"@henrygd/semaphore": "^0.0.2",
|
||||||
"@lingui/macro": "^4.14.1",
|
"@lingui/detect-locale": "^5.2.0",
|
||||||
"@lingui/react": "^4.14.1",
|
"@lingui/macro": "^5.2.0",
|
||||||
|
"@lingui/react": "^5.2.0",
|
||||||
"@nanostores/react": "^0.7.3",
|
"@nanostores/react": "^0.7.3",
|
||||||
"@nanostores/router": "^0.11.0",
|
"@nanostores/router": "^0.11.0",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.6",
|
"@radix-ui/react-alert-dialog": "^1.1.6",
|
||||||
@@ -48,7 +49,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lingui/cli": "^5.2.0",
|
"@lingui/cli": "^5.2.0",
|
||||||
"@lingui/swc-plugin": "^5.4.0",
|
"@lingui/swc-plugin": "^5.5.0",
|
||||||
"@lingui/vite-plugin": "^5.2.0",
|
"@lingui/vite-plugin": "^5.2.0",
|
||||||
"@types/bun": "^1.2.4",
|
"@types/bun": "^1.2.4",
|
||||||
"@types/react": "^18.3.1",
|
"@types/react": "^18.3.1",
|
||||||
|
@@ -11,7 +11,7 @@ const routes = {
|
|||||||
* The base path of the application.
|
* The base path of the application.
|
||||||
* This is used to prepend the base path to all routes.
|
* This is used to prepend the base path to all routes.
|
||||||
*/
|
*/
|
||||||
export const basePath = window.BASE_PATH || ""
|
export const basePath = globalThis.BESZEL.BASE_PATH || ""
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepends the base path to the given path.
|
* Prepends the base path to the given path.
|
||||||
|
3
beszel/site/src/types.d.ts
vendored
3
beszel/site/src/types.d.ts
vendored
@@ -2,8 +2,9 @@ import { RecordModel } from "pocketbase"
|
|||||||
|
|
||||||
// global window properties
|
// global window properties
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
var BESZEL: {
|
||||||
BASE_PATH: string
|
BASE_PATH: string
|
||||||
|
HUB_VERSION: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@ import { defineConfig } from "vite"
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
import react from "@vitejs/plugin-react-swc"
|
import react from "@vitejs/plugin-react-swc"
|
||||||
import { lingui } from "@lingui/vite-plugin"
|
import { lingui } from "@lingui/vite-plugin"
|
||||||
|
import { version } from "./package.json"
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: "./",
|
base: "./",
|
||||||
@@ -10,6 +11,13 @@ export default defineConfig({
|
|||||||
plugins: [["@lingui/swc-plugin", {}]],
|
plugins: [["@lingui/swc-plugin", {}]],
|
||||||
}),
|
}),
|
||||||
lingui(),
|
lingui(),
|
||||||
|
{
|
||||||
|
name: "replace version in index.html during dev",
|
||||||
|
apply: "serve",
|
||||||
|
transformIndexHtml(html) {
|
||||||
|
return html.replace("{{V}}", version)
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
esbuild: {
|
esbuild: {
|
||||||
legalComments: "external",
|
legalComments: "external",
|
||||||
|
Reference in New Issue
Block a user