-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathvite.config.js
More file actions
31 lines (27 loc) · 1004 Bytes
/
vite.config.js
File metadata and controls
31 lines (27 loc) · 1004 Bytes
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
// vite.config.js
import { defineConfig } from "vite";
import { createHtmlPlugin } from "vite-plugin-html";
import { viteSingleFile } from "vite-plugin-singlefile";
import fs from "node:fs";
import path from "node:path";
import { execSync } from "node:child_process";
process.env.VITE_GIT_COMMIT_HASH = execSync("git rev-parse HEAD").toString().trim(); // only updated on vite restart
export default defineConfig(({ mode }) => ({
root: "sources",
base: "/Task-Checklist/",
plugins: [
createHtmlPlugin({
minify: true,
inject: {
data: {
criticalCss: `<style type="text/css">\n${fs.readFileSync(path.resolve(__dirname, "sources/css/critical.css"), "utf-8")}\n</style>`,
},
},
}),
mode === "release" ? viteSingleFile({removeViteModuleLoader: true}) : null,
],
build: {
outDir: mode === "release" ? "../release" : "../pages",
emptyOutDir: true,
},
}));