Fix version build

This commit is contained in:
Arnaud 2024-09-26 19:44:35 +02:00
parent f9d9807cee
commit dea9078379
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
4 changed files with 7 additions and 6 deletions

View File

@ -103,7 +103,7 @@ const Layout = () => {
children={<Outlet />}
items={items}
Right={Right}
version={__APP_VERSION__}
version={import.meta.env.PACKAGE_VERSION}
/>
);
};

3
src/vite-env.d.ts vendored
View File

@ -1,11 +1,10 @@
/// <reference types='vite/client' />
declare const __APP_VERSION__: string;
interface ImportMetaEnv {
VITE_CODEX_API_URL: string;
}
interface ImportMeta {
readonly PACKAGE_VERSION: string;
readonly env: ImportMetaEnv;
}

View File

@ -7,7 +7,8 @@
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true,
"noEmit": true
"noEmit": true,
"resolveJsonModule": true
},
"include": ["vite.config.ts"]
"include": ["vite.config.ts", "./package.json"]
}

View File

@ -1,12 +1,13 @@
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import packageJson from "./package.json";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [TanStackRouterVite(), react()],
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
"import.meta.env.PACKAGE_VERSION": JSON.stringify(packageJson.version),
},
build: {
sourcemap: true,