Skip to content

Commit a7172b9

Browse files
committed
fix: vite config
1 parent c261afc commit a7172b9

File tree

8 files changed

+38
-5
lines changed

8 files changed

+38
-5
lines changed

.github/workflows/deploy-gh-pages.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535

3636
- name: Build
3737
run: npm run build
38+
env:
39+
GITHUB_REF_NAME: ${{ github.ref_name }}
3840

3941
- name: Upload artifact
4042
uses: actions/upload-pages-artifact@v3

demo/package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"react-dom": "^18.2.0"
2121
},
2222
"devDependencies": {
23+
"@types/node": "^22.10.1",
2324
"@types/react": "^18.2.66",
2425
"@types/react-dom": "^18.2.22",
2526
"@typescript-eslint/eslint-plugin": "^7.2.0",
@@ -31,4 +32,4 @@
3132
"typescript": "^5.2.2",
3233
"vite": "^5.2.0"
3334
}
34-
}
35+
}
Binary file not shown.

demo/vite.config.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react-swc'
33

4+
// basePathを構築
5+
const getBasePath = () => {
6+
// GitHub Actionsの場合
7+
if (process.env.GITHUB_REF_NAME) {
8+
const branch = process.env.GITHUB_REF_NAME === 'main'
9+
? ''
10+
: process.env.GITHUB_REF_NAME
11+
return `/postgresql-cst-parser/${branch}`
12+
}
13+
// ローカル開発の場合
14+
return '/'
15+
}
16+
417
// https://vitejs.dev/config/
518
export default defineConfig({
619
plugins: [react()],
7-
// base: '/postgresql-cst-parser/',
8-
base: '/',
20+
base: getBasePath(),
921
build: {
1022
outDir: '../docs',
1123
}

docs/assets/index-n6ysAqyF.js renamed to docs/assets/index-TBTGSimw.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
88
<title>PostgreSQL CST Parser</title>
9-
<script type="module" crossorigin src="/assets/index-n6ysAqyF.js"></script>
9+
<script type="module" crossorigin src="/assets/index-TBTGSimw.js"></script>
1010
<link rel="stylesheet" crossorigin href="/assets/index-B9SYGAMP.css">
1111
</head>
1212

0 commit comments

Comments
 (0)