-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathdefine.config.mjs
More file actions
33 lines (26 loc) · 1.08 KB
/
Copy pathdefine.config.mjs
File metadata and controls
33 lines (26 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import fs from "node:fs"
import { spawnSync } from "node:child_process"
import packageJson from "./package.json" with { type: "json" }
// Read CHANGELOG.md file into a string.
const changelog = fs.readFileSync("./CHANGELOG.md", "utf-8")
// Get the current git commit hash.
const gitCommit = spawnSync("git", ["rev-parse", "--short", "HEAD"])
.stdout.toString()
.trim()
// Don't forget to add your added variables to vite-env.d.ts also!
// These variables are available in your Vue components and will be replaced by their values at build time.
// These will be compiled into your app. Don't store secrets here!
const raw = {
VERSION: packageJson.version,
NAME: packageJson.name,
DISPLAY_NAME: packageJson.displayName,
CHANGELOG: changelog,
GIT_COMMIT: gitCommit,
GITHUB_URL: packageJson.repository.url,
// Set the HTML title for all pages from package.json so you can use %HTMLTITLE% in your HTML files.
HTML_TITLE: packageJson.displayName,
}
const define = Object.fromEntries(
Object.entries(raw).map(([k, v]) => [`__${ k }__`, JSON.stringify(v)])
)
export { raw, define }