zyd-server-build2 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/index.js +24 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,6 +70,24 @@ zsb({
|
|
|
70
70
|
ignoreFile: ["../.gitmodules"], // 需要忽略的文件(完整路径),文件路径前需要包含src的内容,如实例,忽略后不会被打包到目标文件夹中
|
|
71
71
|
noDeleteDir: [".git", "node_modules"], // 需要忽略删除的文件或文件夹,默认:[".git", "node_modules"]
|
|
72
72
|
copyright: "Powered by zydsoft™", // 版权申明
|
|
73
|
+
options: { // 压缩选项
|
|
74
|
+
drop_console: true, // 删除console
|
|
75
|
+
dead_code: true, // 移除没被引用的代码
|
|
76
|
+
drop_debugger: true, // 移除 debugger;
|
|
77
|
+
hoist_funs: true, // 提升函数声明
|
|
78
|
+
join_vars: true, // 合并连续 var 声明
|
|
79
|
+
booleans: true, // 优化布尔运算,例如 !!a? b : c → a ? b : c
|
|
80
|
+
loops: true, // 当do、while 、 for循环的判断条件可以确定是,对其进行优化。
|
|
81
|
+
hoist_vars: true, // (默认 false) -- 提升 var 声明 (默认是false,因为那会加大文件的size)
|
|
82
|
+
properties: false, // (默认 false) — 传一个对象来自定义指明混淆对象属性的选项。
|
|
83
|
+
unsafe_math: true, // (默认 false) -- 优化数字表达式,例如2 * x * 3 变成 6 * x, 可能会导致不精确的浮点数结果。
|
|
84
|
+
unused: true, // 干掉没有被引用的函数和变量。(除非设置"keep_assign",否则变量的简单直接赋值也不算被引用。)
|
|
85
|
+
pure_getters: true, // 默认是 false. 如果你传入true,会假设对象属性的引用(例如foo.bar 或 foo["bar"])没有函数副作用。
|
|
86
|
+
passes: 10, // 默认 1。运行压缩的次数。在某些情况下,用一个大于1的数字参数可以进一步压缩代码大小。注意:数字越大压缩耗时越长。
|
|
87
|
+
global_defs: {
|
|
88
|
+
DEBUG: false
|
|
89
|
+
},
|
|
90
|
+
}
|
|
73
91
|
})
|
|
74
92
|
```
|
|
75
93
|
## License
|
package/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const path = require("path")
|
|
|
10
10
|
const count = [0, 0, 0]
|
|
11
11
|
const timer = []
|
|
12
12
|
|
|
13
|
-
function build ({ src, dst, ignoreDir = [], ignoreFile = [], copyright = "", noBuildFile = [], noBuildDir = [], confused = 1 }) {
|
|
13
|
+
function build ({ src, dst, ignoreDir = [], ignoreFile = [], copyright = "", noBuildFile = [], noBuildDir = [], confused = 1, options = {} }) {
|
|
14
14
|
if (!src || !dst) {
|
|
15
15
|
return
|
|
16
16
|
}
|
|
@@ -41,41 +41,14 @@ function build ({ src, dst, ignoreDir = [], ignoreFile = [], copyright = "", noB
|
|
|
41
41
|
return
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
// 输出Babel命令的标准输出和标准错误
|
|
45
|
-
// console.log(`标准输出:${stdout}`);
|
|
46
|
-
// console.error(`标准错误:${stderr}`);
|
|
47
44
|
readable = await fs.readFileSync(_dst, 'utf-8')
|
|
48
45
|
const result = await minify(readable, {
|
|
49
46
|
parse: {
|
|
50
47
|
// parse options
|
|
51
48
|
},
|
|
52
|
-
compress:
|
|
53
|
-
// drop_console: false, // 删除console
|
|
54
|
-
// dead_code: true, // 移除没被引用的代码
|
|
55
|
-
// drop_debugger: true, // 移除 debugger;
|
|
56
|
-
// hoist_funs: true, // 提升函数声明
|
|
57
|
-
// join_vars: true, // 合并连续 var 声明
|
|
58
|
-
// booleans: true, // 优化布尔运算,例如 !!a? b : c → a ? b : c
|
|
59
|
-
// loops: true, // 当do、while 、 for循环的判断条件可以确定是,对其进行优化。
|
|
60
|
-
// hoist_vars: true, // (默认 false) -- 提升 var 声明 (默认是false,因为那会加大文件的size)
|
|
61
|
-
// properties: false, // (默认 false) — 传一个对象来自定义指明混淆对象属性的选项。
|
|
62
|
-
// unsafe_math: true, // (默认 false) -- 优化数字表达式,例如2 * x * 3 变成 6 * x, 可能会导致不精确的浮点数结果。
|
|
63
|
-
// unused: true, // 干掉没有被引用的函数和变量。(除非设置"keep_assign",否则变量的简单直接赋值也不算被引用。)
|
|
64
|
-
// pure_getters: true, // 默认是 false. 如果你传入true,UglifyJS会假设对象属性的引用(例如foo.bar 或 foo["bar"])没有函数副作用。
|
|
65
|
-
// keep_fnames: true, // 默认 false。传 true来防止压缩器干掉函数名。对那些依赖
|
|
66
|
-
// passes: 10, // 默认 1。运行压缩的次数。在某些情况下,用一个大于1的数字参数可以进一步压缩代码大小。注意:数字越大压缩耗时越长。
|
|
67
|
-
// global_defs: {
|
|
68
|
-
// DEBUG: false
|
|
69
|
-
// },
|
|
70
|
-
},
|
|
49
|
+
compress: options,
|
|
71
50
|
mangle: {
|
|
72
51
|
// mangle options
|
|
73
|
-
// toplevel: true, // 干掉顶层作用域中没有被引用的函数 ("funcs")和/或变量("vars") (默认是false , true 的话即函数变量都干掉)
|
|
74
|
-
// keep_fnames: true, // 默认 false。传 true来防止压缩器干掉函数名。对那些依赖
|
|
75
|
-
// eval: true, // 混淆那些在with或eval中出现的名字(默认禁用)。
|
|
76
|
-
// properties: {
|
|
77
|
-
// // mangle property options
|
|
78
|
-
// }
|
|
79
52
|
},
|
|
80
53
|
format: {
|
|
81
54
|
// format options (can also use `output` for backwards compatibility)
|
|
@@ -85,12 +58,12 @@ function build ({ src, dst, ignoreDir = [], ignoreFile = [], copyright = "", noB
|
|
|
85
58
|
},
|
|
86
59
|
ecma: 2016, // specify one of: 5, 2015, 2016, etc.
|
|
87
60
|
enclose: false, // or specify true, or "args:values"
|
|
88
|
-
keep_classnames: false,
|
|
89
|
-
keep_fnames: true,
|
|
90
61
|
ie8: false,
|
|
91
62
|
module: true,
|
|
92
63
|
nameCache: null, // or specify a name cache object
|
|
93
64
|
safari10: false,
|
|
65
|
+
keep_classnames: true, // 默认 false。传 true来防止压缩器干掉对象名。对那些依赖
|
|
66
|
+
keep_fnames: true, // 默认 false。传 true来防止压缩器干掉函数名。对那些依赖
|
|
94
67
|
toplevel: false
|
|
95
68
|
})
|
|
96
69
|
await fs.writeFileSync(_dst, (copyright ? "/* " + copyright + " */" : "") + result.code)
|
|
@@ -220,6 +193,24 @@ module.exports = ({
|
|
|
220
193
|
noBuildFile = [],
|
|
221
194
|
noBuildDir = [],
|
|
222
195
|
noDeleteDir = [".git", "node_modules"],
|
|
196
|
+
options = {
|
|
197
|
+
drop_console: true, // 删除console
|
|
198
|
+
dead_code: true, // 移除没被引用的代码
|
|
199
|
+
drop_debugger: true, // 移除 debugger;
|
|
200
|
+
hoist_funs: true, // 提升函数声明
|
|
201
|
+
join_vars: true, // 合并连续 var 声明
|
|
202
|
+
booleans: true, // 优化布尔运算,例如 !!a? b : c → a ? b : c
|
|
203
|
+
loops: true, // 当do、while 、 for循环的判断条件可以确定是,对其进行优化。
|
|
204
|
+
hoist_vars: true, // (默认 false) -- 提升 var 声明 (默认是false,因为那会加大文件的size)
|
|
205
|
+
properties: false, // (默认 false) — 传一个对象来自定义指明混淆对象属性的选项。
|
|
206
|
+
unsafe_math: true, // (默认 false) -- 优化数字表达式,例如2 * x * 3 变成 6 * x, 可能会导致不精确的浮点数结果。
|
|
207
|
+
unused: true, // 干掉没有被引用的函数和变量。(除非设置"keep_assign",否则变量的简单直接赋值也不算被引用。)
|
|
208
|
+
pure_getters: true, // 默认是 false. 如果你传入true,会假设对象属性的引用(例如foo.bar 或 foo["bar"])没有函数副作用。
|
|
209
|
+
passes: 10, // 默认 1。运行压缩的次数。在某些情况下,用一个大于1的数字参数可以进一步压缩代码大小。注意:数字越大压缩耗时越长。
|
|
210
|
+
global_defs: {
|
|
211
|
+
DEBUG: false
|
|
212
|
+
},
|
|
213
|
+
}
|
|
223
214
|
} = {}) => {
|
|
224
215
|
console.log(`\x1B[33m
|
|
225
216
|
┌─────────────────────┐
|
|
@@ -230,7 +221,7 @@ module.exports = ({
|
|
|
230
221
|
console.log("\x1B[36m\x1B[1mStart build...\x1B[0m\x1B[0m")
|
|
231
222
|
timer[0] = new Date()
|
|
232
223
|
exists(dst, noDeleteDir)
|
|
233
|
-
build({ src, dst, ignoreDir, ignoreFile, copyright, noBuildFile, noBuildDir })
|
|
224
|
+
build({ src, dst, ignoreDir, ignoreFile, copyright, noBuildFile, noBuildDir, options })
|
|
234
225
|
console.log("")
|
|
235
226
|
console.log(`number of files: \x1B[36m${count[0]}\x1B[0m`)
|
|
236
227
|
console.log(`confusion number: \x1B[36m${count[1]}\x1B[0m`)
|
|
@@ -242,5 +233,5 @@ module.exports = ({
|
|
|
242
233
|
│ build success √ │
|
|
243
234
|
└─────────────────┘
|
|
244
235
|
\x1B[0m\x1B[0m`)
|
|
245
|
-
|
|
236
|
+
console.log('Please wait...')
|
|
246
237
|
}
|