-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvite.config.ts
More file actions
55 lines (50 loc) · 1.48 KB
/
Copy pathvite.config.ts
File metadata and controls
55 lines (50 loc) · 1.48 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { execSync } from "node:child_process";
import { readFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vite";
import { localDebugSitePlugin } from "./src/site/localDebugSitePlugin";
const CONFIG_DIR = path.dirname(fileURLToPath(import.meta.url));
function cssQuakeVersion(): string {
try {
const commitCount = execSync("git rev-list --count HEAD", {
encoding: "utf8",
stdio: ["ignore", "pipe", "ignore"],
}).trim();
return `0.${commitCount}`;
} catch {
return "0.0";
}
}
function polyCssVersion(): string {
try {
const packageJson = JSON.parse(
readFileSync(path.join(CONFIG_DIR, "node_modules/@layoutit/polycss/package.json"), "utf8"),
) as { version?: unknown };
return typeof packageJson.version === "string" ? packageJson.version : "0.0.0";
} catch {
return "0.0.0";
}
}
function localDebugSiteEnabled(): boolean {
return process.env.CSSQUAKE_LOCAL_DEBUG_SITE === "1";
}
export default defineConfig({
plugins: localDebugSiteEnabled() ? [localDebugSitePlugin()] : [],
define: {
__CSSQUAKE_VERSION__: JSON.stringify(cssQuakeVersion()),
__POLYCSS_VERSION__: JSON.stringify(polyCssVersion()),
},
publicDir: "build/generated/public",
build: {
assetsInlineLimit(filePath) {
if (/main-menu-.*\.(?:png)$/u.test(filePath)) {
return false;
}
return undefined;
},
},
server: {
host: "127.0.0.1",
},
});