aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/common.mjs23
1 files changed, 15 insertions, 8 deletions
diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs
index 59153a6..deb8ff4 100644
--- a/scripts/build/common.mjs
+++ b/scripts/build/common.mjs
@@ -1,5 +1,6 @@
import { execSync } from "child_process";
import esbuild from "esbuild";
+import { existsSync } from "fs";
import { readdir } from "fs/promises";
const watch = process.argv.includes("--watch");
@@ -41,21 +42,27 @@ export const globPlugins = {
});
build.onLoad({ filter: /^plugins$/, namespace: "import-plugins" }, async () => {
- const files = await readdir("./src/plugins");
+ const pluginDirs = ["plugins", "userplugins"];
let code = "";
let plugins = "\n";
- for (let i = 0; i < files.length; i++) {
- if (files[i] === "index.ts") {
- continue;
+ let i = 0;
+ for (const dir of pluginDirs) {
+ if (!existsSync(`./src/${dir}`)) continue;
+ const files = await readdir(`./src/${dir}`);
+ for (const file of files) {
+ if (file === "index.ts") {
+ continue;
+ }
+ const mod = `p${i}`;
+ code += `import ${mod} from "./${dir}/${file.replace(/.tsx?$/, "")}";\n`;
+ plugins += `[${mod}.name]:${mod},\n`;
+ i++;
}
- const mod = `p${i}`;
- code += `import ${mod} from "./${files[i].replace(/.tsx?$/, "")}";\n`;
- plugins += `[${mod}.name]:${mod},\n`;
}
code += `export default {${plugins}};`;
return {
contents: code,
- resolveDir: "./src/plugins"
+ resolveDir: "./src"
};
});
}