chore(release): 更新压缩脚本
This commit is contained in:
164
mini-optimizer.config.js
Normal file
164
mini-optimizer.config.js
Normal file
@@ -0,0 +1,164 @@
|
||||
// mini-optimizer 极限压缩配置文件
|
||||
module.exports = {
|
||||
// JavaScript 压缩配置 - 极限压缩
|
||||
minifyJs: {
|
||||
// 启用压缩
|
||||
enabled: true,
|
||||
// 压缩选项
|
||||
options: {
|
||||
// 删除所有注释
|
||||
comments: false,
|
||||
// 删除 console 语句
|
||||
drop_console: true,
|
||||
// 删除 debugger 语句
|
||||
drop_debugger: true,
|
||||
// 启用最高级别的压缩
|
||||
compress: {
|
||||
// 启用所有压缩选项
|
||||
passes: 2,
|
||||
// 删除未使用的变量和函数
|
||||
unused: true,
|
||||
// 删除死代码
|
||||
dead_code: true,
|
||||
// 内联函数调用
|
||||
inline: true,
|
||||
// 折叠常量
|
||||
collapse_vars: true,
|
||||
// 合并变量
|
||||
merge_vars: true,
|
||||
// 简化表达式
|
||||
simplify: true,
|
||||
// 计算常量表达式
|
||||
evaluate: true,
|
||||
// 移除空块
|
||||
drop_empty: true,
|
||||
// 合并相同的函数
|
||||
join_vars: true,
|
||||
// 内联单引用的函数
|
||||
inline_functions: true,
|
||||
// 移除未使用的函数参数
|
||||
unused_params: true
|
||||
},
|
||||
// 混淆选项
|
||||
mangle: {
|
||||
// 启用混淆
|
||||
toplevel: true,
|
||||
// 混淆变量名
|
||||
keep_fnames: false,
|
||||
// 混淆函数名
|
||||
keep_classnames: false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// CSS 压缩配置 - 极限压缩
|
||||
minifyCss: {
|
||||
// 启用压缩
|
||||
enabled: true,
|
||||
// 压缩级别:2 是最高级别
|
||||
level: 2,
|
||||
// 压缩选项
|
||||
options: {
|
||||
// 删除所有注释
|
||||
comments: false,
|
||||
// 合并选择器
|
||||
mergeSelectors: true,
|
||||
// 合并相同的规则
|
||||
mergeRules: true,
|
||||
// 移除空规则
|
||||
removeEmpty: true,
|
||||
// 移除未使用的选择器
|
||||
removeUnused: true,
|
||||
// 简化颜色值
|
||||
convertColors: true,
|
||||
// 缩短十六进制颜色
|
||||
shorthandHex: true,
|
||||
// 移除不必要的分号
|
||||
removeLastSemicolon: true,
|
||||
// 压缩字体权重
|
||||
fontWeights: true,
|
||||
// 压缩 URL
|
||||
urls: true
|
||||
}
|
||||
},
|
||||
|
||||
// XS 文件压缩配置
|
||||
minifyXs: {
|
||||
enabled: true,
|
||||
options: {
|
||||
// 与 JS 压缩选项类似
|
||||
comments: false,
|
||||
drop_console: true,
|
||||
drop_debugger: true,
|
||||
compress: {
|
||||
passes: 2,
|
||||
unused: true,
|
||||
dead_code: true,
|
||||
inline: true,
|
||||
collapse_vars: true,
|
||||
merge_vars: true,
|
||||
simplify: true,
|
||||
evaluate: true,
|
||||
drop_empty: true,
|
||||
join_vars: true
|
||||
},
|
||||
mangle: {
|
||||
toplevel: true,
|
||||
keep_fnames: false,
|
||||
keep_classnames: false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// XML/WXML 文件压缩配置
|
||||
minifyXml: {
|
||||
enabled: true,
|
||||
options: {
|
||||
// 移除所有空格
|
||||
removeWhitespace: true,
|
||||
// 移除所有注释
|
||||
removeComments: true,
|
||||
// 压缩属性值
|
||||
minifyAttributes: true,
|
||||
// 移除空属性
|
||||
removeEmptyAttributes: true,
|
||||
// 移除 CDATA 标签(如果可能)
|
||||
removeCDATASectionsIfNotRequired: true,
|
||||
// 合并相邻文本节点
|
||||
collapseWhitespace: true
|
||||
}
|
||||
},
|
||||
|
||||
// JSON 文件压缩配置
|
||||
minifyJson: {
|
||||
enabled: true,
|
||||
options: {
|
||||
// 移除所有空格和换行
|
||||
space: '',
|
||||
// 移除所有注释
|
||||
comments: false,
|
||||
// 压缩对象键
|
||||
minifyKeys: true,
|
||||
// 移除空值
|
||||
removeEmptyValues: true
|
||||
}
|
||||
},
|
||||
|
||||
// WXSS 文件压缩配置(与 CSS 相同)
|
||||
minifyWxss: {
|
||||
enabled: true,
|
||||
level: 2,
|
||||
options: {
|
||||
comments: false,
|
||||
mergeSelectors: true,
|
||||
mergeRules: true,
|
||||
removeEmpty: true,
|
||||
removeUnused: true,
|
||||
convertColors: true,
|
||||
shorthandHex: true,
|
||||
removeLastSemicolon: true,
|
||||
fontWeights: true,
|
||||
urls: true
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user