diff --git a/web/apps/web-ele/vite.config.mts b/web/apps/web-ele/vite.config.mts index bb4cefd..4f9d8b0 100644 --- a/web/apps/web-ele/vite.config.mts +++ b/web/apps/web-ele/vite.config.mts @@ -1,5 +1,6 @@ import { defineConfig } from '@vben/vite-config'; +import { readFileSync } from 'node:fs'; import { fileURLToPath, URL } from 'node:url'; import ElementPlus from 'unplugin-element-plus/vite'; @@ -8,6 +9,9 @@ import { loadEnv } from 'vite'; const resolveLocal = (path: string) => fileURLToPath(new URL(path, import.meta.url)); const appDir = fileURLToPath(new URL('.', import.meta.url)); +const appVersion = + JSON.parse(readFileSync(resolveLocal('./package.json'), 'utf-8')).version || + '0.0.0'; const exactAlias = (find: string, path: string) => ({ find: new RegExp(`^${find.replaceAll('/', '\\/')}$`), @@ -30,6 +34,9 @@ export default defineConfig(async (config) => { build: { modulePreload: false, }, + define: { + 'import.meta.env.VITE_APP_VERSION': JSON.stringify(appVersion), + }, resolve: { alias: [ exactAlias(