-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
37 lines (32 loc) · 1.13 KB
/
vite.config.ts
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
34
35
36
37
import child_process from "child_process";
import fs from "fs";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
const commitHash = child_process
.execSync("git rev-parse --short HEAD")
.toString()
.trim();
export default defineConfig({
plugins: [
react(),
{
name: "postbuild_commands",
closeBundle: () => {
const path = "./dist/manifest.json";
const manifest = JSON.parse(fs.readFileSync(path).toString());
// We can't load this setting without a search engine defined in Chromium thanks to this bug:
// https://issues.chromium.org/issues/41418973
// So only bundle it into Firefox, it's needed for new windows in Firefox to use the override.
if (process.env.FIREFOX_BUILD) {
manifest.chrome_settings_overrides = { homepage: "index.html" };
}
manifest.version = process.env.npm_package_version;
fs.writeFileSync(path, JSON.stringify(manifest, null, 4));
},
},
],
define: {
APP_VERSION: JSON.stringify(process.env.npm_package_version),
COMMIT_HASH: JSON.stringify(commitHash),
},
});