mirror of
https://gitee.com/bimuziyan/ccc-obfuscated-code.git
synced 2026-06-03 09:20:59 +08:00
支持 [Bundle] 和 [小游戏子包] 的代码混淆
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
### 1.0.3.20200802 (当前版本)
|
||||
### 1.0.4.20200808 (当前版本)
|
||||
|
||||
1. 支持 [Bundle] 和 [小游戏子包] 的代码混淆
|
||||
|
||||
|
||||
|
||||
### 1.0.3.20200802
|
||||
|
||||
1. 支持 Cocos Creator 2.4.x
|
||||
2. 去除【需要混淆的文件】选项
|
||||
|
||||
27
main.js
27
main.js
@@ -4,6 +4,7 @@ const JavascriptObfuscator = require('javascript-obfuscator');
|
||||
|
||||
const configFileDir = 'local/';
|
||||
const configFileName = 'ccc-obfuscated-code.json';
|
||||
|
||||
const defaultConfig = {
|
||||
auto: false,
|
||||
// extraFiles: [],
|
||||
@@ -93,25 +94,17 @@ module.exports = {
|
||||
Editor.log('[CC]', '已混淆代码文件', srcPath);
|
||||
}
|
||||
// Cocos Creator 2.4 以上
|
||||
const assets = Fs.readdirSync(Path.join(options.dest, 'assets'));
|
||||
for (const name of assets) {
|
||||
if (name === 'internal' || name === 'resources') continue;
|
||||
const filePath = Path.join(options.dest, 'assets', name, 'index.js');
|
||||
if (Fs.existsSync(filePath)) {
|
||||
obfuscate(filePath, config.options);
|
||||
Editor.log('[CC]', '已混淆代码文件', filePath);
|
||||
}
|
||||
}
|
||||
// 子包
|
||||
const subpackages = Fs.readdirSync(Path.join(options.dest, 'subpackages'));
|
||||
for (const name of subpackages) {
|
||||
const _names = Fs.readdirSync(Path.join(options.dest, 'subpackages', name));
|
||||
for (const _name of _names) {
|
||||
const filePath = Path.join(options.dest, 'subpackages', name, _name);
|
||||
if (Path.extname(filePath) === '.js') {
|
||||
const list = ['assets', 'subpackages'];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const dirPath = Path.join(options.dest, list[i]);
|
||||
if (!Fs.existsSync(dirPath)) continue;
|
||||
const names = Fs.readdirSync(dirPath);
|
||||
for (const name of names) {
|
||||
if (list[i] === 'assets' && (name === 'internal' || name === 'resources')) continue;
|
||||
const filePath = Path.join(dirPath, name, 'index.js');
|
||||
if (Fs.existsSync(filePath)) {
|
||||
obfuscate(filePath, config.options);
|
||||
Editor.log('[CC]', '已混淆代码文件', filePath);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ccc-obfuscated-code",
|
||||
"version": "1.0.3.20200802",
|
||||
"version": "1.0.4.20200808",
|
||||
"description": "代码混淆工具,支持项目构建后自动混淆代码。",
|
||||
"author": "文弱书生陈皮皮",
|
||||
"main": "main.js",
|
||||
|
||||
Reference in New Issue
Block a user