feat: add hash tag

This commit is contained in:
hamster1963
2024-12-03 15:16:36 +08:00
parent 8811904133
commit b84be53ab8
6 changed files with 85 additions and 51 deletions

View File

@@ -2,10 +2,24 @@ import path from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { VitePWA } from "vite-plugin-pwa";
import { execSync } from "child_process";
// Get git commit hash
const getGitHash = () => {
try {
return execSync("git rev-parse --short HEAD").toString().trim();
} catch (e) {
console.log(e);
return "unknown";
}
};
// https://vite.dev/config/
export default defineConfig({
base: "/",
define: {
"import.meta.env.VITE_GIT_HASH": JSON.stringify(getGitHash()),
},
plugins: [
react(),
VitePWA({