2026-06-15 23:23:12 +07:00
|
|
|
import { execSync } from 'child_process'
|
2026-06-15 02:26:16 +07:00
|
|
|
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
|
|
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
|
2026-06-15 23:23:12 +07:00
|
|
|
function getCommitHash(): string {
|
|
|
|
|
if (process.env.GITHUB_SHA) return process.env.GITHUB_SHA.slice(0, 7)
|
|
|
|
|
try {
|
|
|
|
|
const hash = execSync('git rev-parse --short HEAD').toString().trim()
|
2026-06-16 00:23:50 +07:00
|
|
|
const statusOut = execSync('git status --porcelain --untracked-files=no').toString()
|
|
|
|
|
const dirty = statusOut.trim().length > 0
|
2026-06-15 23:23:12 +07:00
|
|
|
return dirty ? `${hash}-dirty` : hash
|
|
|
|
|
} catch {
|
|
|
|
|
return 'unknown'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const commitHash = JSON.stringify(getCommitHash())
|
|
|
|
|
|
2026-06-15 02:26:16 +07:00
|
|
|
export default defineConfig({
|
|
|
|
|
main: {
|
2026-06-15 23:23:12 +07:00
|
|
|
plugins: [externalizeDepsPlugin()],
|
|
|
|
|
define: {
|
|
|
|
|
__COMMIT_HASH__: commitHash
|
|
|
|
|
}
|
2026-06-15 02:26:16 +07:00
|
|
|
},
|
|
|
|
|
preload: {
|
|
|
|
|
plugins: [externalizeDepsPlugin()]
|
|
|
|
|
},
|
|
|
|
|
renderer: {
|
|
|
|
|
plugins: [tailwindcss(), react()]
|
|
|
|
|
}
|
|
|
|
|
})
|