fix(frontend): bundle app version via package.json import instead of Vite define
Some checks failed
CI / build-and-test (pull_request) Has been cancelled
Some checks failed
CI / build-and-test (pull_request) Has been cancelled
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { getHealth } from "../../api";
|
import { getHealth } from "../../api";
|
||||||
|
import { FRONTEND_VERSION } from "../../frontendVersion";
|
||||||
|
|
||||||
export function AppShellFooter(): JSX.Element {
|
export function AppShellFooter(): JSX.Element {
|
||||||
const [backendVersion, setBackendVersion] = useState<string | null>(null);
|
const [backendVersion, setBackendVersion] = useState<string | null>(null);
|
||||||
@@ -27,7 +28,7 @@ export function AppShellFooter(): JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<footer className="app-shell__footer">
|
<footer className="app-shell__footer">
|
||||||
<p className="app-shell__footer-versions">
|
<p className="app-shell__footer-versions">
|
||||||
Версия клиента: {__FRONTEND_VERSION__}
|
Версия клиента: {FRONTEND_VERSION}
|
||||||
<span className="app-shell__footer-sep" aria-hidden="true">
|
<span className="app-shell__footer-sep" aria-hidden="true">
|
||||||
{" · "}
|
{" · "}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
3
frontend/src/frontendVersion.ts
Normal file
3
frontend/src/frontendVersion.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import packageJson from "../package.json";
|
||||||
|
|
||||||
|
export const FRONTEND_VERSION: string = packageJson.version;
|
||||||
2
frontend/src/vite-env.d.ts
vendored
2
frontend/src/vite-env.d.ts
vendored
@@ -1,3 +1 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
declare const __FRONTEND_VERSION__: string;
|
|
||||||
|
|||||||
@@ -1,15 +1,6 @@
|
|||||||
import { readFileSync } from "node:fs";
|
|
||||||
import path from "node:path";
|
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
||||||
const pkg = JSON.parse(readFileSync(path.join(__dirname, "package.json"), "utf-8")) as { version: string };
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
define: {
|
|
||||||
__FRONTEND_VERSION__: JSON.stringify(pkg.version),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user