diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml
index 048ae7d..4153d01 100644
--- a/.github/workflows/build-and-deploy.yml
+++ b/.github/workflows/build-and-deploy.yml
@@ -1,8 +1,11 @@
name: Build & Deploy
on:
- push:
+ workflow_dispatch:
branches: ["main"]
+# on:
+# push:
+# branches: ["main"]
jobs:
deploy:
diff --git a/README.md b/README.md
index a20e6e1..41487a7 100644
--- a/README.md
+++ b/README.md
@@ -46,6 +46,12 @@ npx shadcn-ui@latest add table
npx shadcn-ui@latest add select
```
+### Deploy `gh-pages`
+- change `basenameProd` in `/vite.config.ts`
+- create deploy key `GITHUB_TOKEN` in github `/settings/keys`
+- commit and push changes code
+- setup gihub pages to branch `gh-pages`
+
## License
This project is licensed under the MIT License. See the [LICENSE](https://github.com/hayyi2/shadcn-sample/blob/main/LICENSE) file for details.
diff --git a/src/Router.tsx b/src/Router.tsx
index a1b3be6..2f10256 100644
--- a/src/Router.tsx
+++ b/src/Router.tsx
@@ -73,5 +73,5 @@ export const router = createBrowserRouter([
element: ,
},
], {
- basename: '/shadcn-sample'
+ basename: global.basename
})
diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts
index 11f02fe..c476cbc 100644
--- a/src/vite-env.d.ts
+++ b/src/vite-env.d.ts
@@ -1 +1,5 @@
///
+
+declare const global: {
+ basename: string
+}
diff --git a/vite.config.ts b/vite.config.ts
index 9611f18..13c7e73 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -2,12 +2,23 @@ import path from "path"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"
-export default defineConfig(({ command }) => ({
- base: command === 'serve' ? '/' : '/shadcn-sample/',
- plugins: [react()],
- resolve: {
- alias: {
- "@": path.resolve(__dirname, "./src"),
+const basenameProd = '/shadcn-sample'
+
+export default defineConfig(({ command }) => {
+ const isProd = command === 'build'
+
+ return {
+ base: isProd ? basenameProd : '',
+ plugins: [react()],
+ resolve: {
+ alias: {
+ "@": path.resolve(__dirname, "./src"),
+ },
+ },
+ define: {
+ global: {
+ basename: isProd ? basenameProd : '',
+ },
},
- },
-}))
\ No newline at end of file
+ }
+})
\ No newline at end of file