mirror of https://github.com/curbengh/hexo-yam
fix: neat_js exclude
delete operator previously remove reference including 'options.exclude', use Object.assign to clone 'options' object to prevent that. https://stackoverflow.com/a/33053362
This commit is contained in:
parent
1de8ec2cd9
commit
5a5a6fb504
|
@ -72,14 +72,14 @@ function logicJs (str, data) {
|
|||
}
|
||||
|
||||
// Terser doesn't like unsupported options
|
||||
delete options.enable
|
||||
delete options.exclude
|
||||
let jsLogger = options.logger
|
||||
delete options.logger
|
||||
const jsOptions = Object.assign({}, options)
|
||||
delete jsOptions.enable
|
||||
delete jsOptions.exclude
|
||||
delete jsOptions.logger
|
||||
|
||||
let result = Terser.minify(str, options)
|
||||
let result = Terser.minify(str, jsOptions)
|
||||
let saved = ((str.length - result.code.length) / str.length * 100).toFixed(2)
|
||||
if (jsLogger) {
|
||||
if (options.logger) {
|
||||
let log = hexo.log || console.log
|
||||
log.log('Minify the js: %s [%s saved]', path, saved + '%')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue