mirror of
https://github.com/epistemic-technology/co-intelligence.git
synced 2026-07-22 06:45:17 +00:00
Obsidian ships CodeMirror in its runtime; bundling our own copy is both wasteful (~200 kB) and risky (two CM6 instances in the host). The bundling-by-default also broke pnpm installs because pnpm doesn't hoist devDependencies the way npm does, so Rollup couldn't resolve the import paths. Externalising drops the plugin back to ~620 kB and matches the recommended pattern for Obsidian plugins that use CM6. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import solid from "vite-plugin-solid";
|
|
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
import path from "path";
|
|
|
|
const isWatchMode = process.argv.includes("--watch");
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
solid(),
|
|
viteStaticCopy({
|
|
targets: [{ src: "manifest.json", dest: "." }],
|
|
}),
|
|
viteStaticCopy({
|
|
targets: [{ src: "src/styles.css", dest: "." }],
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
"@assets": path.resolve(__dirname, "./assets"),
|
|
},
|
|
},
|
|
build: {
|
|
watch: isWatchMode ? {} : undefined,
|
|
minify: !isWatchMode,
|
|
sourcemap: !isWatchMode,
|
|
outDir: "dist",
|
|
emptyOutDir: true,
|
|
cssCodeSplit: false,
|
|
lib: {
|
|
entry: path.resolve(__dirname, "src/CoIntelligencePlugin.tsx"),
|
|
formats: ["cjs"], // Obsidian loads CommonJS
|
|
fileName: () => "main.js",
|
|
},
|
|
rollupOptions: {
|
|
// Obsidian's runtime already loads CodeMirror; importing it as a peer
|
|
// keeps our bundle small and avoids two CM6 instances in the host.
|
|
external: [
|
|
"obsidian",
|
|
"electron",
|
|
"@codemirror/state",
|
|
"@codemirror/view",
|
|
],
|
|
output: {
|
|
exports: "named",
|
|
assetFileNames: () => "styles.css", // Always output CSS as styles.css
|
|
entryFileNames: "main.js", // Ensure the main entry file is named correctly
|
|
},
|
|
},
|
|
},
|
|
css: {
|
|
modules: false,
|
|
},
|
|
});
|