remotely-save/esbuild.config.mjs

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-11-28 17:03:17 +00:00
import dotenv from "dotenv/config";
2021-11-27 06:45:46 +00:00
import esbuild from "esbuild";
import process from "process";
// import builtins from 'builtin-modules'
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
*/
`;
2022-01-08 06:43:53 +00:00
console.log(`esbuild version = ${esbuild.version}`);
2021-11-27 06:45:46 +00:00
const prod = process.argv[2] === "production";
2021-11-28 17:03:17 +00:00
const DEFAULT_DROPBOX_APP_KEY = process.env.DROPBOX_APP_KEY || "";
2021-12-28 16:35:46 +00:00
const DEFAULT_ONEDRIVE_CLIENT_ID = process.env.ONEDRIVE_CLIENT_ID || "";
const DEFAULT_ONEDRIVE_AUTHORITY = process.env.ONEDRIVE_AUTHORITY || "";
2021-11-28 17:03:17 +00:00
2021-11-27 06:45:46 +00:00
esbuild
.build({
banner: {
js: banner,
},
2021-12-11 14:45:21 +00:00
loader: {
".svg": "text",
},
2021-11-27 06:45:46 +00:00
entryPoints: ["./src/main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"fs",
"crypto",
2022-02-12 04:28:47 +00:00
"tls",
"net",
2021-11-27 06:45:46 +00:00
// ...builtins
],
format: "cjs",
watch: !prod,
target: "es2016",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
minify: prod,
outfile: "main.js",
2021-11-28 17:03:17 +00:00
define: {
"process.env.DEFAULT_DROPBOX_APP_KEY": `"${DEFAULT_DROPBOX_APP_KEY}"`,
2021-12-28 16:35:46 +00:00
"process.env.DEFAULT_ONEDRIVE_CLIENT_ID": `"${DEFAULT_ONEDRIVE_CLIENT_ID}"`,
"process.env.DEFAULT_ONEDRIVE_AUTHORITY": `"${DEFAULT_ONEDRIVE_AUTHORITY}"`,
2021-11-28 17:03:17 +00:00
},
2021-11-27 06:45:46 +00:00
})
.catch(() => process.exit(1));