mirror of
https://github.com/litruv/Docs-Viewer.git
synced 2026-09-10 10:09:46 +10:00
Port Docs-Viewer to slatehtml as the docs-viewer package.
Replace the classic DOM shell with slate widgets, markdown→slate rendering, and a CI index build that uses build-docs.cjs.
This commit is contained in:
62
vite.config.js
Normal file
62
vite.config.js
Normal file
@@ -0,0 +1,62 @@
|
||||
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"),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user