mirror of https://github.com/curbengh/hexo-yam
uglify3 compatibility
Credit to 8d9f2da8276652ef270e943dbf9dcb648e14ed55
This commit is contained in:
parent
1eb6f3b20a
commit
4745870028
|
@ -34,7 +34,7 @@ neat_html:
|
|||
- **enable** - Enable the plugin. Defaults to `true`.
|
||||
- **logger** - Print log switch. Defaults to `true`.
|
||||
- **exclude**: Exclude files
|
||||
**Note:** there are so many params please see '[HTMLMinifier](https://github.com/kangax/html-minifier)'
|
||||
**Note:** For more options, see '[HTMLMinifier](https://github.com/kangax/html-minifier)'
|
||||
|
||||
----------
|
||||
|
||||
|
@ -65,6 +65,7 @@ neat_js:
|
|||
- **output**: Output options
|
||||
- **compress**: Compress options
|
||||
- **exclude**: Exclude files
|
||||
**Note:** For more options, see '[UglifyJS](https://github.com/mishoo/UglifyJS2)'
|
||||
|
||||
|
||||
## Credits
|
||||
|
|
4
index.js
4
index.js
|
@ -33,9 +33,7 @@ var assign = require('object-assign');
|
|||
output: {},
|
||||
compress: {},
|
||||
exclude: ['*.min.js']
|
||||
}, hexo.config.neat_js, {
|
||||
fromString: true
|
||||
});
|
||||
}, hexo.config.neat_js);
|
||||
|
||||
|
||||
var filter = require('./lib/filter');
|
||||
|
|
|
@ -79,12 +79,14 @@ function logic_js(str, data) {
|
|||
}
|
||||
|
||||
//uglifyjs doesn't like irrelevant options
|
||||
delete options.enable
|
||||
delete options.logger
|
||||
delete options.exclude
|
||||
delete options.enable;
|
||||
delete options.exclude;
|
||||
var js_logger = options.logger;
|
||||
delete options.logger;
|
||||
|
||||
var result = UglifyJS.minify(str, options);
|
||||
var saved = ((str.length - result.code.length) / str.length * 100).toFixed(2);
|
||||
if (options.logger) {
|
||||
if (js_logger) {
|
||||
var log = hexo.log || console.log;
|
||||
log.log('Minify the js: %s [ %s saved]', path, saved + '%');
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "hexo-yam",
|
||||
"description": "Yet Another Minifier. Minify html, js and css",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"readme": "README.md",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
|
|
Loading…
Reference in New Issue