Adjust
This commit is contained in:
parent
bdd8650ba7
commit
58859f52e5
1 changed files with 21 additions and 14 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue