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