mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 01:39:34 +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, "/") + "/"
|
||||
indexFile, _ := fs.ReadFile(site.DistDirFS, "index.html")
|
||||
indexContent := strings.ReplaceAll(string(indexFile), "./", basePath)
|
||||
indexContent = strings.Replace(indexContent, "{{V}}", beszel.Version, 1)
|
||||
// set up static asset serving
|
||||
staticPaths := [2]string{"/static/", "/assets/"}
|
||||
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" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Beszel</title>
|
||||
<script>window.BASE_PATH = "%BASE_URL%"</script>
|
||||
<script>
|
||||
globalThis.BESZEL = {
|
||||
BASE_PATH: "%BASE_URL%",
|
||||
HUB_VERSION: "{{V}}"
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<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",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "0.10.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -12,9 +12,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@henrygd/queue": "^1.0.7",
|
||||
"@lingui/detect-locale": "^4.14.1",
|
||||
"@lingui/macro": "^4.14.1",
|
||||
"@lingui/react": "^4.14.1",
|
||||
"@henrygd/semaphore": "^0.0.2",
|
||||
"@lingui/detect-locale": "^5.2.0",
|
||||
"@lingui/macro": "^5.2.0",
|
||||
"@lingui/react": "^5.2.0",
|
||||
"@nanostores/react": "^0.7.3",
|
||||
"@nanostores/router": "^0.11.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.6",
|
||||
@@ -48,7 +49,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lingui/cli": "^5.2.0",
|
||||
"@lingui/swc-plugin": "^5.4.0",
|
||||
"@lingui/swc-plugin": "^5.5.0",
|
||||
"@lingui/vite-plugin": "^5.2.0",
|
||||
"@types/bun": "^1.2.4",
|
||||
"@types/react": "^18.3.1",
|
||||
|
@@ -11,7 +11,7 @@ const routes = {
|
||||
* The base path of the application.
|
||||
* 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.
|
||||
|
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
|
||||
declare global {
|
||||
interface Window {
|
||||
var BESZEL: {
|
||||
BASE_PATH: string
|
||||
HUB_VERSION: string
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ import { defineConfig } from "vite"
|
||||
import path from "path"
|
||||
import react from "@vitejs/plugin-react-swc"
|
||||
import { lingui } from "@lingui/vite-plugin"
|
||||
import { version } from "./package.json"
|
||||
|
||||
export default defineConfig({
|
||||
base: "./",
|
||||
@@ -10,6 +11,13 @@ export default defineConfig({
|
||||
plugins: [["@lingui/swc-plugin", {}]],
|
||||
}),
|
||||
lingui(),
|
||||
{
|
||||
name: "replace version in index.html during dev",
|
||||
apply: "serve",
|
||||
transformIndexHtml(html) {
|
||||
return html.replace("{{V}}", version)
|
||||
},
|
||||
},
|
||||
],
|
||||
esbuild: {
|
||||
legalComments: "external",
|
||||
|
Reference in New Issue
Block a user