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:
weyusi 2019-04-23 12:30:47 +09:30
parent 1de8ec2cd9
commit 5a5a6fb504
1 changed files with 6 additions and 6 deletions

View File

@ -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 + '%')
} }