diff --git a/.dumirc.ts b/.dumirc.ts index 2d8b55a..739a35e 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -3,10 +3,9 @@ import { defineConfig } from 'dumi'; const name = 'cssinjs'; -const isDeployGitHubPage = [ - process.env.GH_PAGE, - process.env.GITHUB_ACTIONS, -].includes('true'); +const isProdSite = + // 不是预览模式 同时是生产环境 + process.env.PREVIEW !== 'true' && process.env.NODE_ENV === 'production'; export default defineConfig({ favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'], @@ -16,6 +15,6 @@ export default defineConfig({ }, outputPath: '.doc', exportStatic: {}, - base: isDeployGitHubPage ? `/${name}/` : '/', - publicPath: isDeployGitHubPage ? `/${name}/` : '/', + base: isProdSite ? `/${name}/` : '/', + publicPath: isProdSite ? `/${name}/` : '/', }); diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index d02059a..c977add 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -15,6 +15,6 @@ jobs: dist: .doc build: | npm install - npm run docs:build + npm run docs:preview - name: Get the preview_url run: echo "url => ${{ steps.preview_step.outputs.preview_url }}" diff --git a/package.json b/package.json index bd725bb..1343490 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,9 @@ "start": "dumi dev", "docs:build": "dumi build", "docs:deploy": "gh-pages -d .doc", + "docs:preview": "PREVIEW=true npm run docs:build", "compile": "father build", - "gh-pages": "GH_PAGE=true npm run docs:build", + "gh-pages": "npm run docs:build", "prepublishOnly": "npm run compile && np --yolo --no-publish", "postpublish": "npm run gh-pages", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",