2025-02-06 20:51:56 +00:00
|
|
|
import { UserConfig, defineConfig } from "vite";
|
|
|
|
|
import path from "path";
|
|
|
|
|
import builtins from "builtin-modules";
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
|
|
|
|
|
|
export default defineConfig(async ({ mode }) => {
|
|
|
|
|
const { resolve } = path;
|
|
|
|
|
const prod = mode === "production";
|
|
|
|
|
|
|
|
|
|
return {
|
2025-02-27 17:07:52 +00:00
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
{
|
|
|
|
|
name: "markdown-loader",
|
|
|
|
|
transform(code, id) {
|
|
|
|
|
if (id.slice(-3) === ".md") {
|
|
|
|
|
return `export default ${JSON.stringify(code)};`;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2025-02-06 20:51:56 +00:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
2025-02-26 09:32:58 +00:00
|
|
|
"@": path.resolve(__dirname, "./src")
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
css: {
|
|
|
|
|
preprocessorOptions: {
|
|
|
|
|
scss: {
|
|
|
|
|
// You can add global Sass variables here if needed
|
|
|
|
|
// additionalData: `@import "@/styles/variables.scss";`,
|
|
|
|
|
},
|
2025-02-06 20:51:56 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
lib: {
|
|
|
|
|
entry: resolve(__dirname, "src/main.ts"),
|
|
|
|
|
name: "main",
|
|
|
|
|
fileName: () => "main.js",
|
|
|
|
|
formats: ["cjs"],
|
|
|
|
|
},
|
|
|
|
|
minify: prod,
|
|
|
|
|
sourcemap: prod ? false : "inline",
|
|
|
|
|
outDir: "./",
|
|
|
|
|
cssCodeSplit: false,
|
|
|
|
|
emptyOutDir: false,
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
input: {
|
|
|
|
|
main: resolve(__dirname, "src/main.ts"),
|
|
|
|
|
},
|
|
|
|
|
output: {
|
|
|
|
|
entryFileNames: "main.js",
|
|
|
|
|
assetFileNames: "styles.css",
|
|
|
|
|
},
|
|
|
|
|
external: [
|
|
|
|
|
"obsidian",
|
|
|
|
|
"electron",
|
|
|
|
|
"@codemirror/autocomplete",
|
|
|
|
|
"@codemirror/collab",
|
|
|
|
|
"@codemirror/commands",
|
|
|
|
|
"@codemirror/language",
|
|
|
|
|
"@codemirror/lint",
|
|
|
|
|
"@codemirror/search",
|
|
|
|
|
"@codemirror/state",
|
|
|
|
|
"@codemirror/view",
|
|
|
|
|
"@lezer/common",
|
|
|
|
|
"@lezer/highlight",
|
|
|
|
|
"@lezer/lr",
|
|
|
|
|
...builtins,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
} as UserConfig;
|
|
|
|
|
});
|