Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
90 lines (86 loc) · 3.13 KB
/
Copy pathwebpack.config.js
File metadata and controls
90 lines (86 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const { PickyObfuscator } = require("./dist/pickyObfuscator");
const isProduction = process.env.NODE_ENV == "production";
const TerserPlugin = require("terser-webpack-plugin");
const config = {
entry: "./test/index.ts",
output: {
path: path.resolve(__dirname, "test_dist"),
},
optimization: {
minimizer: [
new TerserPlugin({
extractComments: {
condition: true,
banner: false,
},
terserOptions: {
sourceMap: true,
ecma: 5,
mangle: true,
output: { comments: false },
},
}),
],
},
plugins: [
new PickyObfuscator({
default: {},
hard: { // High obfuscation, low performance preset
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
deadCodeInjection: true,
deadCodeInjectionThreshold: 1,
identifierNamesGenerator: "hexadecimal", // Doesn't make any since here since the Terser will rename most of them
log: false,
numbersToExpressions: true,
renameGlobals: false, // Single functions usually don't have globals
// selfDefending: true, // Enable only if you know what you are doing
simplify: true,
splitStrings: true,
splitStringsChunkLength: 5,
stringArray: true,
stringArrayCallsTransform: true,
stringArrayEncoding: ["rc4"],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 5,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 5,
stringArrayWrappersType: "function",
stringArrayThreshold: 1,
transformObjectKeys: true,
unicodeEscapeSequence: false
},
["test-custom"]: (code) => {
// This is just to test the custom obscuration. Consider using something else
const randomNumber = Math.floor(Math.random() * 500) + 10000;
const ranString = code.split("").map((e, i) => ((e.charCodeAt(0) + randomNumber)) + i);
return `[${ranString.join(",")}].map((a,i)=>String.fromCharCode(a-${randomNumber}-i)).join('').slice(1,-1)`;
}
}),
],
module: {
rules: [
{
test: /\.(ts|tsx)$/i,
loader: "ts-loader",
exclude: ["/node_modules/"],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".jsx", ".js", "..."],
},
};
module.exports = () => {
if (isProduction) {
config.mode = "production";
} else {
config.mode = "development";
}
return config;
};