refactor: updated vite config to inject add version metadata into the app on build (#841)
* refactor: removes commit.json and used vite.config to load these variables * updated precommit hook * updated the pre start script * updated the workflows
This commit is contained in:
@@ -5,8 +5,24 @@ import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
||||
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
|
||||
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
// Get git hash with fallback
|
||||
const getGitHash = () => {
|
||||
try {
|
||||
return execSync('git rev-parse --short HEAD').toString().trim();
|
||||
} catch {
|
||||
return 'no-git-info';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export default defineConfig((config) => {
|
||||
return {
|
||||
define: {
|
||||
__COMMIT_HASH__: JSON.stringify(getGitHash()),
|
||||
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
|
||||
},
|
||||
build: {
|
||||
target: 'esnext',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user