update at 2025-10-10 17:00:09
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user