update at 2025-10-10 17:00:09

This commit is contained in:
douboer
2025-10-10 17:00:09 +08:00
parent 1309caddc3
commit 86c3beea49
14 changed files with 1248 additions and 81 deletions

View File

@@ -1,6 +1,7 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
import javascriptObfuscatorPlugin from "./tools/esbuild-obfuscator-plugin.mjs";
const banner =
`/*
@@ -10,6 +11,25 @@ if you want to view the source, please visit the github repository of this plugi
`;
const prod = (process.argv[2] === "production");
const obfuscate = prod && process.env.OBFUSCATE === "1";
const plugins = [];
if (obfuscate) {
plugins.push(javascriptObfuscatorPlugin({
compact: false,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
disableConsoleOutput: true,
identifierNamesGenerator: "hexadecimal",
log: false,
renameGlobals: false,
simplify: true,
splitStrings: false,
transformObjectKeys: true,
}));
}
const context = await esbuild.context({
banner: {
@@ -38,6 +58,7 @@ const context = await esbuild.context({
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
plugins,
});
if (prod) {
@@ -45,4 +66,4 @@ if (prod) {
process.exit(0);
} else {
await context.watch();
}
}