Skip to content

Commit 27ae8bc

Browse files
committed
Make base depend on env variable
1 parent d5f5488 commit 27ae8bc

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
- name: Install dependencies
3939
run: npm ci
4040
- name: Build
41+
env:
42+
GITHUB: "yes"
4143
run: npm run build
4244
- name: Setup Pages
4345
uses: actions/configure-pages@v5

vite.config.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ import { defineConfig } from "vite";
22
import react from "@vitejs/plugin-react-swc";
33
import path from "node:path";
44

5+
declare global {
6+
interface ImportMeta {
7+
env: {
8+
GITHUB: string;
9+
}
10+
}
11+
}
512
// https://vitejs.dev/config/
6-
export default defineConfig(env => {
7-
const base = env.mode === "PRODUCTION" ? "/SkapEdit/" : "/";
13+
export default defineConfig(() => {
14+
console.log("GITHUB:", import.meta.env?.GITHUB);
15+
16+
const base = import.meta.env?.GITHUB !== undefined
17+
? "/SkapEdit/"
18+
: "/";
819
console.log("Base:", base);
20+
921
return {
1022
plugins: [react()],
1123
base,

0 commit comments

Comments
 (0)