From 7594022cbc2f5e8941de0c5fd46acb84b9a547d9 Mon Sep 17 00:00:00 2001 From: charlzyx Date: Tue, 16 Jan 2024 21:16:56 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=8E=A1=20doc=20site=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/doc.yml | 12 ++++-------- package.json | 4 +++- rspress.config.ts | 11 ++++------- scripts/fixcss.ts | 11 +++++++++++ scripts/switch.js | 9 +++++---- 5 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 scripts/fixcss.ts diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index eee9180..1945c79 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -24,18 +24,14 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 # Not needed if lastUpdated is not enabled - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: yarn - name: Setup Pages uses: actions/configure-pages@v3 + - name: Setup Bun + uses: oven-sh/setup-bun@v1 - name: Install dependencies - run: yarn install + run: bun i - name: Build with Rspress - run: | - yarn run build:docs + run: bun run build:docs - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: diff --git a/package.json b/package.json index 6a6ae49..3c39ed6 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "dev": "rspress dev", "v4": "node scripts/switch.js antd dev && rspress dev", "v5": "node scripts/switch.js antd-v5 dev && rspress dev", - "build:docs": "node scripts/switch.js antd && rspress build", + "build:docs:v4": "node scripts/switch.js antd && rspress build", + "build:docs:v5": "node scripts/switch.js antd-v5 && rspress build", + "build:docs": "npm run build:docs:v4 && npm run build:docs:v5", "preview": "rspress preview" }, "dependencies": { diff --git a/rspress.config.ts b/rspress.config.ts index 4fc8482..1a0786e 100644 --- a/rspress.config.ts +++ b/rspress.config.ts @@ -2,10 +2,12 @@ import * as path from "path"; import { pluginPreview } from "@rspress/plugin-preview"; import { defineConfig } from "rspress/config"; import RsBuildConfig from "./rsbuild.config"; +import { pluginFixCss } from "./scripts/fixcss"; export default defineConfig({ - base: "/pro.formily/", + base: "/pro.formily/antd-v5/", root: path.join(__dirname, "docs"), + outDir: "./doc_build/antd-v5", title: "ProFormily", description: "Pro Formily, 启动!", icon: "/rspress-icon.png", @@ -17,12 +19,7 @@ export default defineConfig({ builderConfig: { ...RsBuildConfig, }, - plugins: [ - pluginPreview(), - () => { - require("./scripts/patch.js"); - }, - ], + plugins: [pluginPreview(), pluginFixCss()], themeConfig: { socialLinks: [ { diff --git a/scripts/fixcss.ts b/scripts/fixcss.ts new file mode 100644 index 0000000..7a0a6d6 --- /dev/null +++ b/scripts/fixcss.ts @@ -0,0 +1,11 @@ +import { RspressPlugin } from "@rspress/shared"; + +export function pluginFixCss(): RspressPlugin { + return { + name: "fix-css", + afterBuild(config, isProd) { + require("./patch"); + }, + builderConfig: {}, + }; +} diff --git a/scripts/switch.js b/scripts/switch.js index 98aaec9..e81479c 100644 --- a/scripts/switch.js +++ b/scripts/switch.js @@ -49,13 +49,16 @@ const replaeer = (c) => { return c .replace(`@formily/antd-v5"`, `@formily/antd"`) .replace(`@proformily/antd-v5"`, `@proformily/antd"`) - .replace(`proformily-antd-v5"`, `proformily-antd"`) + .replace(`/pro.formily/antd-v5"`, `/pro.formily/antd"`) + .replace(`/doc_build/antd-v5"`, `/doc_build/antd"`) .replace("antd/dist/reset.css", "antd/dist/antd.css"); } else { return c .replace(`@formily/antd"`, `@formily/antd-v5"`) .replace(`@proformily/antd"`, `@proformily/antd-v5"`) .replace(`proformily-antd"`, `proformily-antd-v5"`) + .replace(`/pro.formily/antd"`, `/pro.formily/antd-v5"`) + .replace(`/doc_build/antd"`, `/doc_build/antd-v5"`) .replace("antd/dist/antd.css", "antd/dist/reset.css"); } }; @@ -78,11 +81,10 @@ rmrf.sync(shadow); if (mode === "dev") { execSync(`rm -rf ${shadow}`); execSync(`ln -s ${ui} ${shadow}`); + rmrf.sync(path.resolve(__dirname, "../doc_build")); } else { execSync(`rm -rf ${shadow}`); execSync(`cp -R ${ui} ${shadow}`); - rmrf.sync(path.resolve(__dirname, "../node_modules")); - rmrf.sync(path.resolve(__dirname, "../doc_build")); } const pkgPath = path.resolve(__dirname, "../package.json"); const pkg = JSON.parse(fs.readFileSync(pkgPath)); @@ -110,6 +112,5 @@ pkg.dependencies = { fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), "utf-8"); rmrf.sync(path.resolve(__dirname, "../node_modules")); -rmrf.sync(path.resolve(__dirname, "../doc_build")); execSync("bun i"); console.log("ready for --", adaptor);