From 1516510027938cfe017c6f6f53990f0fbae6e574 Mon Sep 17 00:00:00 2001 From: Uyarn Date: Sun, 7 Apr 2024 16:25:41 +0800 Subject: [PATCH] feat: support preview --- .github/workflows/preview-publish.yml | 20 ++++++++++++++++++++ package.json | 1 + site/package.json | 1 + site/vite.config.js | 3 ++- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/preview-publish.yml diff --git a/.github/workflows/preview-publish.yml b/.github/workflows/preview-publish.yml new file mode 100644 index 00000000..737299e3 --- /dev/null +++ b/.github/workflows/preview-publish.yml @@ -0,0 +1,20 @@ +# 文件名建议统一为 preview-publish +# 应用 preview.yml 的 demo +name: PREVIEW_PUBLISH + +on: + workflow_run: + workflows: ['MAIN_PULL_REQUEST'] + types: + - completed + +jobs: + build-site: + runs-on: ubuntu-latest + steps: + - name: build-site + run: npm run site:preview + call-preview: + uses: Tencent/tdesign/.github/workflows/preview.yml@main + secrets: + TDESIGN_SURGE_TOKEN: ${{ secrets.TDESIGN_SURGE_TOKEN }} diff --git a/package.json b/package.json index 18f76d50..80d9b96d 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build:components": "pnpm run --filter 'tdesign-site-components' build && pnpm run --filter 'tdesign-site-components' postbuild", "site": "npm run build:components && cd site && npm run build", "site:intranet": "npm run build:components && cd site && npm run site:intranet", + "site:preview": "npm run build:components && cd site && npm run site:preview", "prepare": "husky install" }, "license": "MIT", diff --git a/site/package.json b/site/package.json index 1054f896..c961d2d8 100644 --- a/site/package.json +++ b/site/package.json @@ -7,6 +7,7 @@ "preview": "vite preview", "site": "run-s build", "site:intranet": "vite build --mode intranet", + "site:preview": "vite build --mode preview", "lint:fix": "eslint --ext .vue,.js,.ts,.tsx ./src --fix" }, "dependencies": { diff --git a/site/vite.config.js b/site/vite.config.js index 6315e9f2..e9af713e 100644 --- a/site/vite.config.js +++ b/site/vite.config.js @@ -5,6 +5,7 @@ import tdocPlugin from './plugin-tdoc/index.js'; const publicPathMap = { intranet: '/', + preview: '/', production: 'https://static.tdesign.tencent.com/', }; @@ -23,7 +24,7 @@ export default ({ mode }) => { }, }, build: { - outDir: '_site', + outDir: mode === 'preview' ? '../_site' : '_site', rollupOptions: { input: { index: path.resolve(__dirname, 'index.html'),