2021-10-25 15:45:15 +00:00
|
|
|
import esbuild from "esbuild";
|
|
|
|
|
import process from "process";
|
2025-10-19 05:49:35 +00:00
|
|
|
import {builtinModules} from "module";
|
2021-10-25 15:45:15 +00:00
|
|
|
|
2025-03-22 10:12:11 +00:00
|
|
|
const banner =
|
|
|
|
|
`/*
|
2025-03-16 05:42:02 +00:00
|
|
|
* Xiaohongshu Importer plugin
|
|
|
|
|
* Author: bnchiang96
|
2025-10-19 05:49:35 +00:00
|
|
|
* Version: 1.1.2
|
2025-03-16 05:42:02 +00:00
|
|
|
*/
|
2021-10-25 15:45:15 +00:00
|
|
|
`;
|
|
|
|
|
|
2025-03-22 10:12:11 +00:00
|
|
|
const prod = (process.argv[2] === "production");
|
2021-10-25 15:45:15 +00:00
|
|
|
|
2025-03-22 10:12:11 +00:00
|
|
|
const context = await esbuild.context({
|
2021-11-01 19:17:03 +00:00
|
|
|
banner: {
|
|
|
|
|
js: banner,
|
|
|
|
|
},
|
2023-01-25 18:49:50 +00:00
|
|
|
entryPoints: ["main.ts"],
|
2021-11-01 19:17:03 +00:00
|
|
|
bundle: true,
|
2022-01-10 14:01:38 +00:00
|
|
|
external: [
|
2023-01-25 18:49:50 +00:00
|
|
|
"obsidian",
|
|
|
|
|
"electron",
|
2025-03-22 10:12:11 +00:00
|
|
|
"@codemirror/autocomplete",
|
|
|
|
|
"@codemirror/collab",
|
|
|
|
|
"@codemirror/commands",
|
|
|
|
|
"@codemirror/language",
|
|
|
|
|
"@codemirror/lint",
|
|
|
|
|
"@codemirror/search",
|
|
|
|
|
"@codemirror/state",
|
|
|
|
|
"@codemirror/view",
|
|
|
|
|
"@lezer/common",
|
|
|
|
|
"@lezer/highlight",
|
|
|
|
|
"@lezer/lr",
|
2025-10-19 05:49:35 +00:00
|
|
|
...builtinModules],
|
2023-01-25 18:49:50 +00:00
|
|
|
format: "cjs",
|
2025-03-22 10:12:11 +00:00
|
|
|
target: "es2018",
|
|
|
|
|
logLevel: "info",
|
|
|
|
|
sourcemap: prod ? false : "inline",
|
|
|
|
|
treeShaking: true,
|
2023-01-25 18:49:50 +00:00
|
|
|
outfile: "main.js",
|
2023-11-15 19:10:43 +00:00
|
|
|
minify: prod,
|
2025-03-22 10:12:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (prod) {
|
|
|
|
|
await context.rebuild();
|
|
|
|
|
process.exit(0);
|
|
|
|
|
} else {
|
|
|
|
|
await context.watch();
|
|
|
|
|
}
|