mirror of
https://github.com/litruv/Docs-Viewer.git
synced 2026-09-10 01:59:44 +10:00
Replace the classic DOM shell with slate widgets, markdown→slate rendering, and a CI index build that uses build-docs.cjs.
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
import { defineConfig } from "vite";
|
|
import { createRequire } from "node:module";
|
|
import { cpSync, existsSync } from "node:fs";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { umc } from "slatehtml/umc/vite";
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const uiSrc = join(dirname(require.resolve("slatehtml-ui/package.json")), "src");
|
|
const docsSrc = join(here, "src");
|
|
|
|
function copyDocsStatic() {
|
|
const paths = ["index.json", "docs", "img", "example.index.json"];
|
|
return {
|
|
name: "copy-docs-static",
|
|
writeBundle(outputOptions) {
|
|
const outDir = outputOptions.dir || join(here, "dist");
|
|
for (const name of paths) {
|
|
const from = join(here, name);
|
|
if (!existsSync(from)) continue;
|
|
cpSync(from, join(outDir, name), { recursive: true });
|
|
}
|
|
},
|
|
};
|
|
}
|
|
|
|
export default defineConfig({
|
|
root: here,
|
|
base: "./",
|
|
plugins: [umc({ roots: [uiSrc, docsSrc] }), copyDocsStatic()],
|
|
server: {
|
|
fs: {
|
|
allow: [here, join(here, "..", "slatehtml")],
|
|
},
|
|
},
|
|
build: {
|
|
target: "es2022",
|
|
outDir: "dist",
|
|
emptyOutDir: true,
|
|
},
|
|
resolve: {
|
|
alias: [
|
|
{
|
|
find: "slatehtml-ui/configure",
|
|
replacement: join(uiSrc, "configure.js"),
|
|
},
|
|
{
|
|
find: "slatehtml-ui/icons/fontawesome",
|
|
replacement: join(uiSrc, "fontawesome-icons.js"),
|
|
},
|
|
{
|
|
find: "slatehtml-ui/icons/lucide",
|
|
replacement: join(uiSrc, "lucide-icons.js"),
|
|
},
|
|
{
|
|
find: "docs-viewer/prose.css",
|
|
replacement: join(docsSrc, "prose.css"),
|
|
},
|
|
],
|
|
},
|
|
});
|