Stage 1: app skeleton — Electron window, sidebar/editor layout, light/dark CSS, esbuild build, typecheck
This commit is contained in:
commit
6fac0d013b
12 changed files with 2488 additions and 0 deletions
62
esbuild.config.mjs
Normal file
62
esbuild.config.mjs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
import esbuild from "esbuild";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const watch = process.argv.includes("--watch");
|
||||
|
||||
const copyAssets = {
|
||||
name: "copy-assets",
|
||||
setup(build) {
|
||||
build.onEnd(() => {
|
||||
fs.mkdirSync("dist", { recursive: true });
|
||||
fs.copyFileSync(
|
||||
path.join("src", "renderer", "index.html"),
|
||||
path.join("dist", "index.html")
|
||||
);
|
||||
fs.copyFileSync(
|
||||
path.join("src", "renderer", "index.css"),
|
||||
path.join("dist", "index.css")
|
||||
);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const common = {
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
logLevel: "info",
|
||||
};
|
||||
|
||||
const main = {
|
||||
entryPoints: ["src/main/index.ts"],
|
||||
platform: "node",
|
||||
external: ["electron"],
|
||||
outfile: "dist/main.js",
|
||||
plugins: [copyAssets],
|
||||
...common,
|
||||
};
|
||||
|
||||
const preload = {
|
||||
entryPoints: ["src/main/preload.ts"],
|
||||
platform: "node",
|
||||
external: ["electron"],
|
||||
outfile: "dist/preload.js",
|
||||
plugins: [copyAssets],
|
||||
...common,
|
||||
};
|
||||
|
||||
const renderer = {
|
||||
entryPoints: ["src/renderer/index.ts"],
|
||||
platform: "browser",
|
||||
outfile: "dist/renderer.js",
|
||||
...common,
|
||||
};
|
||||
|
||||
const builds = [main, preload, renderer];
|
||||
|
||||
if (watch) {
|
||||
const contexts = await Promise.all(builds.map((opts) => esbuild.context(opts)));
|
||||
await Promise.all(contexts.map((ctx) => ctx.watch()));
|
||||
} else {
|
||||
await Promise.all(builds.map((opts) => esbuild.build(opts)));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue