feat: init
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import esbuild from "esbuild";
|
||||
import process from "node:process";
|
||||
import builtins from "builtin-modules";
|
||||
import sveltePlugin from "esbuild-svelte";
|
||||
|
||||
const prod = process.argv[2] === "production";
|
||||
|
||||
const ctx = await esbuild.context({
|
||||
entryPoints: ["src/main.ts"],
|
||||
bundle: true,
|
||||
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,
|
||||
],
|
||||
// Svelte components ship their scoped ``<style>`` blocks inside the JS
|
||||
// bundle (``css: "injected"``) rather than as a separate stylesheet.
|
||||
// Obsidian only auto-loads a single ``styles.css`` per plugin, and that
|
||||
// slot is taken by the Tailwind output — injecting keeps us to one CSS
|
||||
// artifact instead of two that would have to be concatenated.
|
||||
//
|
||||
// No preprocessor: Svelte 5 strips type-only TS syntax itself, and we
|
||||
// stick to that subset (no enums, no decorators, no parameter
|
||||
// properties) so ``lang="ts"`` components compile as-is.
|
||||
plugins: [
|
||||
sveltePlugin({
|
||||
compilerOptions: { css: "injected", runes: true },
|
||||
}),
|
||||
],
|
||||
format: "cjs",
|
||||
target: "es2022",
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : "inline",
|
||||
treeShaking: true,
|
||||
outfile: "main.js",
|
||||
minify: prod,
|
||||
conditions: ["svelte", "browser"],
|
||||
mainFields: ["svelte", "browser", "module", "main"],
|
||||
});
|
||||
|
||||
if (prod) {
|
||||
await ctx.rebuild();
|
||||
await ctx.dispose();
|
||||
} else {
|
||||
await ctx.watch();
|
||||
}
|
||||
Reference in New Issue
Block a user