2022-02-16 11:26:13 +02:00
|
|
|
import esbuild from "esbuild";
|
|
|
|
import process from "process";
|
|
|
|
import builtins from "builtin-modules";
|
|
|
|
import sveltePlugin from "esbuild-svelte";
|
|
|
|
import sveltePreprocess from "svelte-preprocess";
|
2022-07-21 06:06:42 +02:00
|
|
|
import fs from "node:fs";
|
2022-02-16 11:26:13 +02:00
|
|
|
const banner = `/*
|
|
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
|
|
if you want to view the source, please visit the github repository of this plugin
|
|
|
|
*/
|
|
|
|
`;
|
|
|
|
|
|
|
|
const prod = process.argv[2] === "production";
|
2022-07-21 06:06:42 +02:00
|
|
|
const manifestJson = JSON.parse(fs.readFileSync("./manifest.json"));
|
|
|
|
const packageJson = JSON.parse(fs.readFileSync("./package.json"));
|
2022-07-28 12:19:37 +02:00
|
|
|
const updateInfo = JSON.stringify(fs.readFileSync("./updates.md") + "");
|
2022-02-16 11:26:13 +02:00
|
|
|
esbuild
|
|
|
|
.build({
|
|
|
|
banner: {
|
|
|
|
js: banner,
|
|
|
|
},
|
|
|
|
entryPoints: ["src/main.ts"],
|
|
|
|
bundle: true,
|
2022-07-21 06:06:42 +02:00
|
|
|
define: {
|
|
|
|
"MANIFEST_VERSION": `"${manifestJson.version}"`,
|
|
|
|
"PACKAGE_VERSION": `"${packageJson.version}"`,
|
2022-07-28 12:19:37 +02:00
|
|
|
"UPDATE_INFO": `${updateInfo}`,
|
2022-12-27 11:09:51 +02:00
|
|
|
"global":"window",
|
2022-07-21 06:06:42 +02:00
|
|
|
},
|
2022-12-27 11:09:51 +02:00
|
|
|
external: ["obsidian", "electron", "crypto"],
|
2022-02-16 11:26:13 +02:00
|
|
|
format: "cjs",
|
|
|
|
watch: !prod,
|
2022-09-05 09:55:29 +02:00
|
|
|
target: "es2018",
|
2022-02-16 11:26:13 +02:00
|
|
|
logLevel: "info",
|
|
|
|
sourcemap: prod ? false : "inline",
|
|
|
|
treeShaking: true,
|
2022-12-27 11:09:51 +02:00
|
|
|
platform: "browser",
|
2022-02-16 11:26:13 +02:00
|
|
|
plugins: [
|
|
|
|
sveltePlugin({
|
|
|
|
preprocess: sveltePreprocess(),
|
|
|
|
compilerOptions: { css: true },
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
outfile: "main.js",
|
|
|
|
})
|
|
|
|
.catch(() => process.exit(1));
|