File tree Expand file tree Collapse file tree 5 files changed +59
-3
lines changed Expand file tree Collapse file tree 5 files changed +59
-3
lines changed Original file line number Diff line number Diff line change 1+ name : deploy
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ branches :
7+ - v*.x
8+
9+ permissions :
10+ contents : write
11+
12+ jobs :
13+ deploy :
14+ runs-on : ubuntu-latest
15+ env :
16+ VITE_APP_BASENAME : /unplugin-react-pages/
17+ steps :
18+ - uses : actions/checkout@v4
19+ - uses : ./.github/actions/setup
20+ - run : pnpm run docs:build
21+ - uses : peaceiris/actions-gh-pages@v4
22+ with :
23+ github_token : ${{ secrets.GITHUB_TOKEN }}
24+ publish_dir : ./docs/dist
25+ publish_branch : ${{ github.ref_name }}-pages
Original file line number Diff line number Diff line change 1+ namespace NodeJS {
2+ interface ProcessEnv {
3+ /**
4+ * package name
5+ * defined in vite.config.mts
6+ */
7+ PKG_NAME : string ;
8+
9+ /**
10+ * package version
11+ * defined in vite.config.mts
12+ */
13+ PKG_VERSION : string ;
14+
15+ /**
16+ * vite 应用基础路径
17+ * Github deploy action
18+ */
19+ VITE_APP_BASENAME ?: string ;
20+
21+ }
22+ }
Original file line number Diff line number Diff line change @@ -6,9 +6,11 @@ import 'virtual:uno.css';
66import 'virtual:svg-icons-register' ;
77import App from './App' ;
88
9+ const basename = process . env . VITE_APP_BASENAME || '/' ;
10+
911ReactDOM . createRoot ( document . getElementById ( 'root' ) ! ) . render (
1012 < StrictMode >
11- < HashRouter basename = "/" >
13+ < HashRouter basename = { basename } >
1214 < App />
1315 </ HashRouter >
1416 </ StrictMode > ,
Original file line number Diff line number Diff line change @@ -12,11 +12,17 @@ import { defineConfig } from 'vite';
1212import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' ;
1313import { ViteMinifyPlugin } from 'vite-plugin-minify' ;
1414import { reactPages } from '../src' ;
15+ import pkg from './package.json' ;
1516
1617export default defineConfig ( {
18+ base : process . env . VITE_APP_BASENAME || '/' ,
1719 server : {
1820 port : 15170 ,
1921 } ,
22+ define : {
23+ 'process.env.PKG_NAME' : JSON . stringify ( pkg . name ) ,
24+ 'process.env.PKG_VERSION' : JSON . stringify ( pkg . version ) ,
25+ } ,
2026 plugins : [
2127 // plugins
2228 react ( ) ,
Original file line number Diff line number Diff line change 5757 "test" : " vitest run" ,
5858 "test:coverage" : " vitest run --coverage" ,
5959 "build" : " NODE_ENV=production vite build" ,
60- "pre-commit" : " echo 0" ,
61- "pre-commit1" : " pnpm run lint:type"
60+ "docs:dev" : " pnpm -F 'docs' run dev" ,
61+ "docs:build" : " pnpm -F 'docs' run build" ,
62+ "pre-commit" : " pnpm run lint:type"
6263 },
6364 "workspaces" : [
6465 " docs"
You can’t perform that action at this time.
0 commit comments