mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 23:49:27 +08:00
fix: pro plugin build
This commit is contained in:
parent
53f2ff4779
commit
abbe88e46c
@ -362,12 +362,21 @@ export async function buildProPluginServer(cwd: string, userConfig: UserConfig,
|
||||
// plugin-commercial build to a bundle
|
||||
const externalOptions = {
|
||||
external: [],
|
||||
noExternal: []
|
||||
noExternal: [],
|
||||
onSuccess: async () => {},
|
||||
esbuildPlugins: [],
|
||||
};
|
||||
// other plugins build to a bundle just include plugin-commercial
|
||||
if (!cwd.includes(PLUGIN_COMMERCIAL)) {
|
||||
externalOptions.external = [/^[./]/];
|
||||
externalOptions.noExternal = [entryFile, /@nocobase\/plugin-commercial\/server/, /dist\/server\/index\.js/];
|
||||
externalOptions.onSuccess = async () => {
|
||||
const serverFiles = [path.join(cwd, target_dir, 'server', 'index.js')];
|
||||
serverFiles.forEach((file) => {
|
||||
obfuscate(file);
|
||||
});
|
||||
};
|
||||
externalOptions.esbuildPlugins = [pluginEsbuildCommercialInject];
|
||||
}
|
||||
|
||||
// bundle all files、inject commercial code and obfuscate
|
||||
@ -384,20 +393,14 @@ export async function buildProPluginServer(cwd: string, userConfig: UserConfig,
|
||||
sourcemap,
|
||||
outDir: path.join(cwd, target_dir, 'server'),
|
||||
format: 'cjs',
|
||||
...externalOptions,
|
||||
skipNodeModulesBundle: true,
|
||||
tsconfig: tsconfig.path,
|
||||
loader: {
|
||||
...otherExts.reduce((prev, cur) => ({ ...prev, [cur]: 'copy' }), {}),
|
||||
'.json': 'copy',
|
||||
},
|
||||
esbuildPlugins: [pluginEsbuildCommercialInject],
|
||||
onSuccess: async () => {
|
||||
const serverFiles = [path.join(cwd, target_dir, 'server', 'index.js')];
|
||||
serverFiles.forEach((file) => {
|
||||
obfuscate(file);
|
||||
});
|
||||
},
|
||||
|
||||
...externalOptions,
|
||||
}),
|
||||
);
|
||||
fs.removeSync(tsconfig.path);
|
||||
|
@ -14,34 +14,29 @@ export const obfuscate = (filePath: string) => {
|
||||
const fileContent = fs.readFileSync(filePath, 'utf8');
|
||||
const obfuscationResult = JavaScriptObfuscator.obfuscate(fileContent, {
|
||||
compact: true,
|
||||
controlFlowFlattening: true,
|
||||
controlFlowFlatteningThreshold: 0.75,
|
||||
deadCodeInjection: true,
|
||||
deadCodeInjectionThreshold: 0.4,
|
||||
controlFlowFlattening: false,
|
||||
deadCodeInjection: false,
|
||||
debugProtection: false,
|
||||
debugProtectionInterval: 0,
|
||||
disableConsoleOutput: true,
|
||||
identifierNamesGenerator: 'hexadecimal',
|
||||
log: false,
|
||||
numbersToExpressions: true,
|
||||
numbersToExpressions: false,
|
||||
renameGlobals: false,
|
||||
selfDefending: true,
|
||||
simplify: true,
|
||||
splitStrings: true,
|
||||
splitStringsChunkLength: 10,
|
||||
splitStrings: false,
|
||||
stringArray: true,
|
||||
stringArrayCallsTransform: true,
|
||||
stringArrayCallsTransformThreshold: 0.75,
|
||||
stringArrayEncoding: ['base64'],
|
||||
stringArrayCallsTransform: false,
|
||||
stringArrayEncoding: [],
|
||||
stringArrayIndexShift: true,
|
||||
stringArrayRotate: true,
|
||||
stringArrayShuffle: true,
|
||||
stringArrayWrappersCount: 2,
|
||||
stringArrayWrappersCount: 1,
|
||||
stringArrayWrappersChainedCalls: true,
|
||||
stringArrayWrappersParametersMaxCount: 4,
|
||||
stringArrayWrappersType: 'function',
|
||||
stringArrayWrappersParametersMaxCount: 2,
|
||||
stringArrayWrappersType: 'variable',
|
||||
stringArrayThreshold: 0.75,
|
||||
transformObjectKeys: true,
|
||||
unicodeEscapeSequence: false
|
||||
});
|
||||
fs.writeFileSync(filePath, obfuscationResult.getObfuscatedCode(), 'utf8');
|
||||
|
Loading…
x
Reference in New Issue
Block a user