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
|
// Terser doesn't like unsupported options
|
||||||
delete options.enable
|
const jsOptions = Object.assign({}, options)
|
||||||
delete options.exclude
|
delete jsOptions.enable
|
||||||
let jsLogger = options.logger
|
delete jsOptions.exclude
|
||||||
delete options.logger
|
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)
|
let saved = ((str.length - result.code.length) / str.length * 100).toFixed(2)
|
||||||
if (jsLogger) {
|
if (options.logger) {
|
||||||
let log = hexo.log || console.log
|
let log = hexo.log || console.log
|
||||||
log.log('Minify the js: %s [%s saved]', path, saved + '%')
|
log.log('Minify the js: %s [%s saved]', path, saved + '%')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue