Skip to content

Commit

Permalink
ci: 🎡 doc site build
Browse files Browse the repository at this point in the history
  • Loading branch information
charlzyx committed Jan 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent de44e5d commit 7594022
Showing 5 changed files with 27 additions and 20 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -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:
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
11 changes: 4 additions & 7 deletions rspress.config.ts
Original file line number Diff line number Diff line change
@@ -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: [
{
11 changes: 11 additions & 0 deletions scripts/fixcss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { RspressPlugin } from "@rspress/shared";

export function pluginFixCss(): RspressPlugin {
return {
name: "fix-css",
afterBuild(config, isProd) {
require("./patch");
},
builderConfig: {},
};
}
9 changes: 5 additions & 4 deletions scripts/switch.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 7594022

Please sign in to comment.