-
Notifications
You must be signed in to change notification settings - Fork 50
/
webpack.config.js
102 lines (100 loc) · 2.64 KB
/
webpack.config.js
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
91
92
93
94
95
96
97
98
99
100
101
102
const { execSync } = require('child_process')
const path = require('path')
const { DefinePlugin } = require('webpack')
const WebpackObfuscator = require('webpack-obfuscator')
const { version } = require('./package.json')
const commitHash = (() => {
try {
return execSync('git rev-parse --short HEAD')
.toString()
.trim()
} catch (err) {
console.log(err)
return 'unknown'
}
})()
module.exports = {
mode: 'production',
target: 'node',
entry: {
mainEntry: './buildDev/entry/mainEntry.js',
workerEntry: './buildDev/entry/workerEntry.js'
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'build')
}
]
},
resolve: {
extensions: ['.js'],
symlinks: false
},
plugins: [
new DefinePlugin({
'process.env': {
BUILD_INFO: `"production v${version} [${commitHash}]"`,
COMMIT_HASH: `"${commitHash}"`
}
}),
new WebpackObfuscator({
compact: true,
controlFlowFlattening: false,
controlFlowFlatteningThreshold: 0,
deadCodeInjection: false,
deadCodeInjectionThreshold: 0.3,
debugProtection: false,
debugProtectionInterval: 2e3,
disableConsoleOutput: false,
forceTransformStrings: [],
identifierNamesCache: null,
identifierNamesGenerator: 'mangled',
identifiersDictionary: [],
identifiersPrefix: '',
ignoreRequireImports: false,
inputFileName: '',
log: false,
numbersToExpressions: false,
optionsPreset: 'default',
renameGlobals: false,
renameProperties: false,
renamePropertiesMode: 'safe',
reservedNames: [],
reservedStrings: [],
seed: 0,
selfDefending: true,
simplify: true,
sourceMap: false,
sourceMapBaseUrl: '',
sourceMapFileName: '',
sourceMapMode: 'separate',
sourceMapSourcesMode: 'sources-content',
splitStrings: true,
splitStringsChunkLength: 5,
stringArray: true,
stringArrayCallsTransform: true,
stringArrayCallsTransformThreshold: 0.6,
stringArrayEncoding: [],
stringArrayIndexesType: [
'hexadecimal-number'
],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 2,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 1,
target: 'node',
transformObjectKeys: true,
unicodeEscapeSequence: false
})
],
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'buildRel')
}
}