Skip to content

Commit

Permalink
fix:配置base
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnFishs committed Oct 12, 2024
1 parent 4e57f96 commit b738899
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// process.env.GITHUB_REPOSITORY 存储仓库的全名 GitHub Actions 自动设置的标准环境变量之一
const GITHUB_REPOSITORY = process.env.GITHUB_REPOSITORY || ""

const GITHUB_REPOSITORY = process.env.GITHUB_REPOSITORY || "";
const projectName = GITHUB_REPOSITORY.split("/").pop();
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
base: GITHUB_REPOSITORY ? `/${GITHUB_REPOSITORY}/` : "/", //在git上部署时,需要设置base,在vercel上部署时设置为/即可,
base: projectName ? `/${projectName}/` : "/", //在git上部署时,需要设置base,在vercel上部署时设置为/即可,
build: {
outDir: "dist",
assetsDir: "static",
Expand Down

0 comments on commit b738899

Please sign in to comment.