add hotreload

This commit is contained in:
Brian Petro 2024-05-31 12:06:06 -04:00
parent 05398939be
commit f31c00d378

View file

@ -16,24 +16,26 @@ if you want to view the source, please visit the github repository of this plugi
const prod = (process.argv[2] === "production");
// const copy_to_plugins = {
// name: 'copy_to_plugins',
// setup(build) {
// build.onEnd(() => {
// const plugin_path = path.join(process.env.OBSIDIAN_PLUGINS_PATH, "smart-connections-graph-view");
const copy_to_plugins = {
name: 'copy_to_plugins',
setup(build) {
build.onEnd(() => {
const plugin_path = path.join(process.env.OBSIDIAN_PLUGINS_PATH, "smart-connections-graph-view");
// if (!fs.existsSync(plugin_path)) {
// fs.mkdirSync(plugin_path);
// }
if (!fs.existsSync(plugin_path)) {
fs.mkdirSync(plugin_path);
}
// fs.copyFileSync("./main.js", path.join(plugin_path, "main.js"));
// fs.copyFileSync("./manifest.json", path.join(plugin_path, "manifest.json"));
// fs.copyFileSync("./styles.css", path.join(plugin_path, "styles.css"));
fs.copyFileSync("./main.js", path.join(plugin_path, "main.js"));
fs.copyFileSync("./manifest.json", path.join(plugin_path, "manifest.json"));
fs.copyFileSync("./styles.css", path.join(plugin_path, "styles.css"));
// add empty .hotreload file
fs.writeFileSync(path.join(plugin_path, ".hotreload"), "");
// console.log("Plugin built and copied to obsidian plugins folder");
// });
// }
// };
console.log("Plugin built and copied to obsidian plugins folder");
});
}
};
const context = await esbuild.context({
banner: {
js: banner,
@ -63,7 +65,7 @@ const context = await esbuild.context({
treeShaking: true,
outfile: "main.js",
plugins: [
// copy_to_plugins
copy_to_plugins
]
});
if(!prod) await context.watch();