-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathvite.config.js
More file actions
101 lines (92 loc) · 2.56 KB
/
vite.config.js
File metadata and controls
101 lines (92 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* Vite Configuration for Vendoring JavaScript Libraries
*
* This config is used by Hugo Blox maintainers to copy third-party
* JavaScript libraries from node_modules into the Hugo module's assets.
*
* Usage: pnpm run vendor:libs
*/
import {resolve} from "node:path";
import del from "rollup-plugin-delete";
import {defineConfig} from "vite";
import {viteStaticCopy} from "vite-plugin-static-copy";
const MODULE_DIR = "modules/blox";
const OUTPUT_DIR = resolve(MODULE_DIR, "assets/dist/lib");
export default defineConfig({
build: {
emptyOutDir: true,
outDir: OUTPUT_DIR,
lib: {
entry: resolve(MODULE_DIR, "assets/js/vendor-libs.js"),
formats: ["es"],
fileName: "vendor-libs",
},
rollupOptions: {
// Don't bundle these libraries, just copy them
external: ["mermaid", "plotly.js", "katex", "markmap-autoloader", "alpinejs"],
},
},
plugins: [
// Copy vendor libraries to module assets
viteStaticCopy({
targets: [
// Mermaid - Diagram rendering
{
src: "node_modules/mermaid/dist/mermaid.min.js",
dest: "mermaid/",
},
// Plotly - Interactive charts
{
src: "node_modules/plotly.js/dist/plotly.min.js",
dest: "plotly/",
},
// KaTeX - Math rendering
{
src: "node_modules/katex/dist/katex.min.js",
dest: "katex/",
},
{
src: "node_modules/katex/dist/katex.min.css",
dest: "katex/",
},
{
src: "node_modules/katex/dist/contrib/auto-render.min.js",
dest: "katex/",
},
{
src: "node_modules/katex/dist/fonts/",
dest: "katex/",
},
// Markmap - Mind map rendering
{
src: "node_modules/markmap-autoloader/dist/index.js",
dest: "markmap/",
},
// Alpine.js
{
src: "node_modules/alpinejs/dist/cdn.min.js",
dest: "alpinejs/",
},
// Preact for interactive components
{
src: "node_modules/preact/dist/preact.min.js",
dest: "preact/",
},
{
src: "node_modules/preact/dist/preact.min.js.map",
dest: "preact/",
},
{
src: "node_modules/preact/hooks/dist/hooks.umd.js",
dest: "preact/",
rename: "hooks.min.js",
},
],
}),
// Clean up any unwanted build artifacts
del({
targets: `${OUTPUT_DIR}/vendor-libs.js`, // Remove the dummy entry file
hook: "writeBundle",
}),
],
});