-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathdefine.config.mjs
29 lines (23 loc) · 1.07 KB
/
define.config.mjs
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
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()
const jsn = (value) => JSON.stringify(value)
// 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!
export const defineViteConfig = {
__VERSION__: jsn(packageJson.version),
__NAME__: jsn(packageJson.name),
__DISPLAY_NAME__: jsn(packageJson.displayName),
__CHANGELOG__: jsn(changelog),
__GIT_COMMIT__: jsn(gitCommit),
__GITHUB_URL__: jsn(packageJson.repository.url),
// Set the HTML title for all pages from package.json so you can use %HTML_TITLE% in your HTML files.
HTML_TITLE: jsn(packageJson.displayName),
}