Файли
l0ng-ai ac71b7008e feat(plugins): Graphviz, Regex Tester, License Header and Harbor Night official plugins
- Graphviz: `.dot` / `.gv` files open beside a live preview (a web view
  rendering with Graphviz compiled to WebAssembly) in any layout engine,
  with zoom, pan, Fit and SVG / PNG export through the save dialog. What
  Graphviz reports goes from the page to the plugin's code, which publishes
  it as problems on the named line. A DOT language, file icons and a
  New Graphviz Graph template.
- Regex Tester: a tool window whose html view sends pattern, flags, text and
  replacement as you type; the plugin matches with Rust's regex (linear time)
  and answers with matches, groups and the replacement in UTF-16 offsets.
  Use Selection and Test Selection take the editor's selection.
- License Header: files without a copyright / SPDX header are reported when
  they open and on save; a quick fix and a command add one in the file's
  comment syntax (after a shebang or encoding line); a project scan in a
  background task reports the rest. Holder and license are settings.
- Harbor Night becomes an official plugin and the one source of the theme
  files: `openidea-plugin new --template theme`, the theme docs and tests
  start from it.
- Tool windows' renders and events carry the window's active editor, as
  commands do, so a view's buttons can act on what the user is editing.
- knip leaves plugins' web pages (projects of their own) alone.
2026-11-04 02:41:46 +08:00

49 рядки
1.6 KiB
TypeScript

/**
* Builds the page into ../web (not checked in: plugins/build.sh builds it).
* Relative URLs throughout: the IDE serves the page from
* the plugin package under its own URL scheme. Excalidraw's fonts are copied
* next to it; the page points Excalidraw at them (src/assets.ts).
*/
import { cpSync, existsSync, rmSync } from "node:fs";
import { createRequire } from "node:module";
import path from "node:path";
import react from "@vitejs/plugin-react";
import type { Plugin } from "vite";
import { defineConfig } from "vitest/config";
const require = createRequire(import.meta.url);
const outDir = path.resolve(import.meta.dirname, "../web");
function excalidrawFonts(): Plugin {
return {
name: "openidea:excalidraw-fonts",
apply: "build",
closeBundle() {
const fonts = path.resolve(path.dirname(require.resolve("@excalidraw/excalidraw")), "fonts");
if (!existsSync(fonts)) throw new Error(`no Excalidraw fonts at ${fonts}`);
rmSync(path.join(outDir, "fonts"), { recursive: true, force: true });
cpSync(fonts, path.join(outDir, "fonts"), { recursive: true });
},
};
}
export default defineConfig({
base: "./",
plugins: [react(), excalidrawFonts()],
define: { "process.env.IS_PREACT": JSON.stringify("false") },
build: {
outDir,
emptyOutDir: true,
target: "es2022",
sourcemap: false,
assetsInlineLimit: 0,
chunkSizeWarningLimit: 4096,
},
test: {
// Excalidraw needs a DOM even for its data API; its packages ship JSON and CSS imports Node can't load.
environment: "jsdom",
setupFiles: ["./src/test-setup.ts"],
server: { deps: { inline: [/@excalidraw/, /open-color/] } },
},
});