This commit is contained in:
Andras Schmelczer 2024-12-18 22:38:51 +00:00
parent bdd8650ba7
commit 58859f52e5
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -5,12 +5,6 @@ import path from "node:path";
import fs from "node:fs";
import { wasmPack } from "esbuild-plugin-wasm-pack";
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";
async function copyFiles(sourceDir, destinationDir) {
@ -76,9 +70,6 @@ let wasmPlugin = {
},
};
const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["src/plugin.ts"],
bundle: true,
external: [
@ -106,14 +97,20 @@ const context = await esbuild.context({
minify: prod,
plugins: [
wasmPlugin,
wasmPack({
target: "web",
path: "../backend/sync_lib",
}),
prod
? null
: wasmPack({
target: "web",
path: "../backend/sync_lib",
}),
{
name: "post-compile",
setup(build) {
build.onEnd((result) => {
if (prod) {
return;
}
if (result.errors.length === 0) {
copyFiles(
["manifest.json", "versions.json", ".hotreload"],
@ -124,11 +121,21 @@ const context = await esbuild.context({
"build",
"/mnt/c/Users/Andras/Desktop/test/test/.obsidian/plugins/my-plugin"
);
copyFiles(
["manifest.json", "versions.json", ".hotreload"],
"/mnt/c/Users/Andras/Desktop/test/test2/.obsidian/plugins/my-plugin"
);
copyFiles(
"build",
"/mnt/c/Users/Andras/Desktop/test/test2/.obsidian/plugins/my-plugin"
);
}
});
},
},
],
].filter(Boolean),
});
if (prod) {