vitepress-plugin-diagrams 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/bin/cli.js +0 -0
- package/package.json +66 -65
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ The diagrams are meant to be generated at __DEV time__ because:
|
|
|
24
24
|
- Clean, semantic HTML output
|
|
25
25
|
- Use can use any editor to create diagrams (for example `VS Code` with `Mermaid` extension)
|
|
26
26
|
- **Import diagrams from external files** using `@file:` syntax
|
|
27
|
+
- **Optional build-time generation** for CI/CD pipelines (diagrams generated during `vitepress build`)
|
|
27
28
|
|
|
28
29
|
## Demo
|
|
29
30
|
|
|
@@ -203,6 +204,58 @@ You can customize the `CSS` classes to match your theme.
|
|
|
203
204
|
- For `positionId`, previous files with the same `diagramType` and `positionId` are removed.
|
|
204
205
|
- Without identifiers, older `[diagramType]-[otherHash].svg` files are removed when content changes.
|
|
205
206
|
|
|
207
|
+
## Build-Time Generation (Optional)
|
|
208
|
+
|
|
209
|
+
By default, diagrams are generated at **dev time** (fire-and-forget fetch with a placeholder SVG). For CI/CD pipelines or when you need diagrams to be reliably generated during `vitepress build`, you can use the **build-time generation** mode.
|
|
210
|
+
|
|
211
|
+
In this mode:
|
|
212
|
+
- Diagram HTTP calls are **deferred** and executed during the Vite build (`generateBundle` hook) or dev server request.
|
|
213
|
+
- The build **fails** if a diagram cannot be generated (e.g., Kroki is unreachable), ensuring broken diagrams are caught early.
|
|
214
|
+
- Already-generated SVGs on disk are reused (not re-fetched).
|
|
215
|
+
|
|
216
|
+
### Setup
|
|
217
|
+
|
|
218
|
+
Use `createBuildTimeDiagramsPlugin` instead of `configureDiagramsPlugin`:
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
import { defineConfig } from "vitepress";
|
|
222
|
+
import { createBuildTimeDiagramsPlugin } from "vitepress-plugin-diagrams";
|
|
223
|
+
|
|
224
|
+
const { configureMarkdown, vitePlugin } = createBuildTimeDiagramsPlugin({
|
|
225
|
+
diagramsDir: "docs/public/diagrams",
|
|
226
|
+
publicPath: "/diagrams",
|
|
227
|
+
// Optional: emit SVGs as build assets at this path
|
|
228
|
+
diagramsDistDir: "diagrams",
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export default defineConfig({
|
|
232
|
+
markdown: {
|
|
233
|
+
config: (md) => configureMarkdown(md),
|
|
234
|
+
},
|
|
235
|
+
vite: {
|
|
236
|
+
plugins: [vitePlugin()],
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
All standard options (`krokiServerUrl`, `excludedDiagramTypes`, `enableFileImports`, etc.) are supported.
|
|
242
|
+
|
|
243
|
+
| Additional Option | Type | Default | Description |
|
|
244
|
+
|-------------------|------|---------|-------------|
|
|
245
|
+
| `diagramsDistDir` | `string` | `undefined` | If set, SVG files are emitted as Vite build assets at this path |
|
|
246
|
+
|
|
247
|
+
### Using with a self-hosted Kroki instance
|
|
248
|
+
|
|
249
|
+
For reliable CI builds, you can run [Kroki via Docker](https://docs.kroki.io/kroki/setup/use-docker-or-podman/) and point the plugin to it:
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
const { configureMarkdown, vitePlugin } = createBuildTimeDiagramsPlugin({
|
|
253
|
+
krokiServerUrl: "http://localhost:8000",
|
|
254
|
+
diagramsDir: "docs/public/diagrams",
|
|
255
|
+
publicPath: "/diagrams",
|
|
256
|
+
});
|
|
257
|
+
```
|
|
258
|
+
|
|
206
259
|
## Note
|
|
207
260
|
|
|
208
261
|
When updating a diagram, you may see a placeholder image on the browser page. This is normal, because the svg file is loaded asynchronously and may not be displayed immediately. Just refresh the page.
|
package/bin/cli.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vitepress-plugin-diagrams",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "VitePress plugin for generating diagrams from text (PlantUML, Mermaid, etc.)",
|
|
5
|
-
"author": "Ruslan Makarov <ruslan.makarov@gmail.com>",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/altrusl/vitepress-plugin-diagrams.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/altrusl/vitepress-plugin-diagrams/issues"
|
|
13
|
-
},
|
|
14
|
-
"homepage": "https://github.com/altrusl/vitepress-plugin-diagrams",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"main": "./dist/index.cjs",
|
|
17
|
-
"module": "./dist/index.js",
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
19
|
-
"exports": {
|
|
20
|
-
".": {
|
|
21
|
-
"import": "./dist/index.js",
|
|
22
|
-
"require": "./dist/index.cjs"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"vite",
|
|
27
|
-
"vitepress-plugin",
|
|
28
|
-
"diagrams",
|
|
29
|
-
"plantuml",
|
|
30
|
-
"mermaid"
|
|
31
|
-
],
|
|
32
|
-
"files": [
|
|
33
|
-
"bin",
|
|
34
|
-
"dist"
|
|
35
|
-
],
|
|
36
|
-
"bin": "bin/cli.js",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "vitepress-plugin-diagrams",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "VitePress plugin for generating diagrams from text (PlantUML, Mermaid, etc.)",
|
|
5
|
+
"author": "Ruslan Makarov <ruslan.makarov@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/altrusl/vitepress-plugin-diagrams.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/altrusl/vitepress-plugin-diagrams/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/altrusl/vitepress-plugin-diagrams",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.cjs",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"vite",
|
|
27
|
+
"vitepress-plugin",
|
|
28
|
+
"diagrams",
|
|
29
|
+
"plantuml",
|
|
30
|
+
"mermaid"
|
|
31
|
+
],
|
|
32
|
+
"files": [
|
|
33
|
+
"bin",
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"bin": "bin/cli.js",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "vite build && pnpm run build:types",
|
|
39
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
40
|
+
"build:cli": "tsc",
|
|
41
|
+
"test": "vitest",
|
|
42
|
+
"test:run": "vitest run",
|
|
43
|
+
"demo:dev": "pnpm --filter vitepress-diagrams-demo dev",
|
|
44
|
+
"demo:build": "pnpm --filter vitepress-diagrams-demo build",
|
|
45
|
+
"publish": "pnpm publish --access public"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"markdown-it": "^14.1.0",
|
|
49
|
+
"commander": "^14.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@sxzz/eslint-config": "^4.6.0",
|
|
53
|
+
"@types/node": "^22.13.1",
|
|
54
|
+
"esbuild": "^0.25.5",
|
|
55
|
+
"eslint": "^9.20.0",
|
|
56
|
+
"typescript": "^5.7.3",
|
|
57
|
+
"undici-types": "^7.10.0",
|
|
58
|
+
"vite": "^6.1.0",
|
|
59
|
+
"vitepress": "^1.6.3",
|
|
60
|
+
"vitest": "^3.0.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"vite": ">= 4.0.0",
|
|
64
|
+
"vitepress": ">= 1.0.0"
|
|
65
|
+
}
|
|
66
|
+
}
|