From 0f3653f0d367e97443195bb433d70f246f869da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=BF=E4=B8=80=E6=97=A5=E7=9A=84=E8=88=B9?= Date: Fri, 23 Aug 2024 20:18:54 +0800 Subject: [PATCH 1/3] =?UTF-8?q?vite=E6=89=93=E5=8C=85=E6=96=B9=E6=A1=88?= =?UTF-8?q?=E6=9C=AA=E6=88=90=E5=8A=9F=E6=9A=82=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- base/index.ts | 1 + base/package.json | 20 ++++++++++++++++++++ base/src/Handbook.vue | 0 base/src/locales.ts | 0 base/src/options.ts | 0 base/src/utils.ts | 16 ++++++++++++++++ base/src/wordless.ts | 0 base/tsconfig.json | 25 +++++++++++++++++++++++++ base/vite.config.ts | 16 ++++++++++++++++ package.json | 1 + pnpm-workspace.yaml | 1 + 12 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 base/index.ts create mode 100644 base/package.json create mode 100644 base/src/Handbook.vue create mode 100644 base/src/locales.ts create mode 100644 base/src/options.ts create mode 100644 base/src/utils.ts create mode 100644 base/src/wordless.ts create mode 100644 base/tsconfig.json create mode 100644 base/vite.config.ts create mode 100644 pnpm-workspace.yaml diff --git a/.gitignore b/.gitignore index 6ccd1ca..2d73bae 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ pnpm-lock.yaml yarn.lock bun.lockb -# VitePress编译输出文件 +# 编译输出文件 docs/.vitepress/cache/ docs/.vitepress/dist/ +dist/ diff --git a/base/index.ts b/base/index.ts new file mode 100644 index 0000000..bf27954 --- /dev/null +++ b/base/index.ts @@ -0,0 +1 @@ +export * from "./src/utils" diff --git a/base/package.json b/base/package.json new file mode 100644 index 0000000..cc0cfae --- /dev/null +++ b/base/package.json @@ -0,0 +1,20 @@ +{ + "name": "vitepress-handbook", + "description": "VitePress构建手册基础设施", + "version": "0.0.0", + "type": "module", + "private": true, + "scripts": { + "build": "vue-tsc -b && vite build" + }, + "dependencies": { + "vitepress": "^1.3.3", + "vue": "^3.4.38" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^5.1.2", + "typescript": "^5.5.4", + "vite": "^5.4.2", + "vue-tsc": "^2.0.29" + } +} diff --git a/base/src/Handbook.vue b/base/src/Handbook.vue new file mode 100644 index 0000000..e69de29 diff --git a/base/src/locales.ts b/base/src/locales.ts new file mode 100644 index 0000000..e69de29 diff --git a/base/src/options.ts b/base/src/options.ts new file mode 100644 index 0000000..e69de29 diff --git a/base/src/utils.ts b/base/src/utils.ts new file mode 100644 index 0000000..0109d7c --- /dev/null +++ b/base/src/utils.ts @@ -0,0 +1,16 @@ +export function ensurePrefix(raw: string, prefix: string) { + return raw.startsWith(prefix) ? raw : prefix + raw +} + +export function ensureSuffix(raw: string, suffix: string) { + return raw.endsWith(suffix) ? raw : raw + suffix +} + +export function removePrefix(raw: string, prefix: string) { + return raw.startsWith(prefix) ? raw.slice(prefix.length) : raw +} + +export function maybeCapitalCase(raw: string | undefined) { + if (!raw) return undefined + return raw.charAt(0).toUpperCase() + raw.slice(1) +} diff --git a/base/src/wordless.ts b/base/src/wordless.ts new file mode 100644 index 0000000..e69de29 diff --git a/base/tsconfig.json b/base/tsconfig.json new file mode 100644 index 0000000..0c587fe --- /dev/null +++ b/base/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + // 打包模式。 + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "preserve", + "declaration": true, + + // 代码检查。 + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["index.ts"] +} diff --git a/base/vite.config.ts b/base/vite.config.ts new file mode 100644 index 0000000..acf7e7d --- /dev/null +++ b/base/vite.config.ts @@ -0,0 +1,16 @@ +import vue from "@vitejs/plugin-vue" +import {defineConfig} from "vite" + +export default defineConfig({ + plugins: [vue()], + build: { + lib: {entry: "index.ts", name: "handbook", fileName: "handbook"}, + sourcemap: true, + outDir: "dist", + emptyOutDir: true, + rollupOptions: { + external: ["vitepress", "vue"], + output: {globals: {vitepress: "VitePress", vue: "Vue"}, compact: false}, + }, + }, +}) diff --git a/package.json b/package.json index b00b40d..174d3b0 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "markdown-it": "^14.1.0", "pagefind": "^1.1.0", "vitepress": "^1.3.3", + "vitepress-handbook": "./base", "vitepress-plugin-pagefind": "^0.4.10", "vue": "^3.4.38" }, diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..3da57b5 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1 @@ +packages: [base] From 752ee4eaa6ec447c3a2c351fc4909240cf3a6c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=BF=E4=B8=80=E6=97=A5=E7=9A=84=E8=88=B9?= Date: Sat, 24 Aug 2024 18:14:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E6=95=8F=E6=84=9F=E8=AF=8D=E8=A2=AB=E5=B0=81?= =?UTF-8?q?=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index a3055aa..98cca94 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,7 +4,7 @@ layout: home hero: name: 数社软件开发手册 text: 知识工程基础设施 - tagline: 先进技术应当掌握在人民群众手中 + tagline: 助您快速形成软件开发生产力 actions: - {theme: brand, text: 如何使用, link: /guide} - {theme: alt, text: 编程规范, link: /spec/intro} From d71eb5525b081ba598c9adc168da6535c36edef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=BF=E4=B8=80=E6=97=A5=E7=9A=84=E8=88=B9?= Date: Sat, 24 Aug 2024 18:15:18 +0800 Subject: [PATCH 3/3] =?UTF-8?q?vite-dts=E4=B8=B4=E6=97=B6=E6=89=93?= =?UTF-8?q?=E5=8C=85=E6=96=B9=E6=A1=88(=E6=9C=AA=E9=AA=8C=E8=AF=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/package.json | 2 ++ base/tsconfig.json | 2 +- base/vite.config.ts | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/base/package.json b/base/package.json index cc0cfae..32b6169 100644 --- a/base/package.json +++ b/base/package.json @@ -13,8 +13,10 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^5.1.2", + "rollup-plugin-dts": "^6.1.1", "typescript": "^5.5.4", "vite": "^5.4.2", + "vite-plugin-dts": "^4.0.3", "vue-tsc": "^2.0.29" } } diff --git a/base/tsconfig.json b/base/tsconfig.json index 0c587fe..0df0895 100644 --- a/base/tsconfig.json +++ b/base/tsconfig.json @@ -21,5 +21,5 @@ "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, - "include": ["index.ts"] + "include": ["index.ts", "src/**/*.ts", "src/**/*.vue"] } diff --git a/base/vite.config.ts b/base/vite.config.ts index acf7e7d..3b21f16 100644 --- a/base/vite.config.ts +++ b/base/vite.config.ts @@ -1,10 +1,16 @@ import vue from "@vitejs/plugin-vue" import {defineConfig} from "vite" +import dts from "vite-plugin-dts" export default defineConfig({ - plugins: [vue()], + plugins: [vue(), dts()], build: { - lib: {entry: "index.ts", name: "handbook", fileName: "handbook"}, + lib: { + entry: "index.ts", + name: "handbook", + fileName: "handbook", + formats: ["es", "umd"], + }, sourcemap: true, outDir: "dist", emptyOutDir: true,