File tree Expand file tree Collapse file tree 2 files changed +77
-6
lines changed
Expand file tree Collapse file tree 2 files changed +77
-6
lines changed Original file line number Diff line number Diff line change 1+ # 一个简单的 GitHub Pages 部署工作流
2+ name : Deploy static content to Pages
3+
4+ on :
5+ # 仅在推送到默认分支时运行
6+ push :
7+ branches : [main]
8+
9+ # 这个选项可以使你手动在 Action tab 页面触发工作流
10+ workflow_dispatch :
11+
12+ # 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
13+ permissions :
14+ contents : read
15+ pages : write
16+ id-token : write
17+
18+ # 允许一个并发部署
19+ concurrency :
20+ group : pages
21+ cancel-in-progress : true
22+
23+ jobs :
24+ # 单次部署的工作描述
25+ deploy :
26+ environment :
27+ name : github-pages
28+ url : ${{ steps.deployment.outputs.page_url }}
29+ runs-on : ubuntu-latest
30+ steps :
31+ - name : Checkout
32+ uses : actions/checkout@v5
33+
34+ - name : Setup pnpm
35+ uses : pnpm/action-setup@v4
36+
37+ - name : Set up Node
38+ uses : actions/setup-node@v4
39+ with :
40+ node-version : lts/*
41+ cache : pnpm
42+ - name : Install dependencies
43+ run : pnpm install
44+ - name : Build
45+ run : pnpm run build
46+ env :
47+ VITE_BASE_PATH : /usb.ids/
48+ - name : Setup Pages
49+ uses : actions/configure-pages@v5
50+ - name : Upload artifact
51+ uses : actions/upload-pages-artifact@v4
52+ with :
53+ # 上传 dist 文件夹
54+ path : ./dist
55+ - name : Deploy to GitHub Pages
56+ id : deployment
57+ uses : actions/deploy-pages@v4
Original file line number Diff line number Diff line change 11import path from 'node:path'
2- import { defineConfig } from 'vite'
2+ import process from 'node:process'
3+ import { defineConfig , loadEnv } from 'vite'
34import usbIdsPlugin from './plugins/plugin-usb-ids'
45
5- export default defineConfig ( {
6- plugins : [ usbIdsPlugin ( {
7- fallbackFile : path . resolve ( __dirname , 'usb.ids.json' ) ,
8- skipInDev : true ,
9- } ) ] ,
6+ export default defineConfig ( ( { command } ) => {
7+ const env = loadEnv ( command , process . cwd ( ) )
8+
9+ const base = env . VITE_BASE_PATH || '/'
10+ console . log ( 'vite base ' , base )
11+
12+ return {
13+ base,
14+ plugins : [
15+ usbIdsPlugin ( {
16+ fallbackFile : path . resolve ( __dirname , 'usb.ids.json' ) ,
17+ skipInDev : true ,
18+ } ) ,
19+ ] ,
20+ build : {
21+ chunkSizeWarningLimit : 2048 ,
22+ } ,
23+ }
1024} )
You can’t perform that action at this time.
0 commit comments