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`.
|
- **enable** - Enable the plugin. Defaults to `true`.
|
||||||
- **logger** - Print log switch. Defaults to `true`.
|
- **logger** - Print log switch. Defaults to `true`.
|
||||||
- **exclude**: Exclude files
|
- **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
|
- **output**: Output options
|
||||||
- **compress**: Compress options
|
- **compress**: Compress options
|
||||||
- **exclude**: Exclude files
|
- **exclude**: Exclude files
|
||||||
|
**Note:** For more options, see '[UglifyJS](https://github.com/mishoo/UglifyJS2)'
|
||||||
|
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
4
index.js
4
index.js
|
@ -33,9 +33,7 @@ var assign = require('object-assign');
|
||||||
output: {},
|
output: {},
|
||||||
compress: {},
|
compress: {},
|
||||||
exclude: ['*.min.js']
|
exclude: ['*.min.js']
|
||||||
}, hexo.config.neat_js, {
|
}, hexo.config.neat_js);
|
||||||
fromString: true
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var filter = require('./lib/filter');
|
var filter = require('./lib/filter');
|
||||||
|
|
|
@ -79,12 +79,14 @@ function logic_js(str, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//uglifyjs doesn't like irrelevant options
|
//uglifyjs doesn't like irrelevant options
|
||||||
delete options.enable
|
delete options.enable;
|
||||||
delete options.logger
|
delete options.exclude;
|
||||||
delete options.exclude
|
var js_logger = options.logger;
|
||||||
|
delete options.logger;
|
||||||
|
|
||||||
var result = UglifyJS.minify(str, options);
|
var result = UglifyJS.minify(str, options);
|
||||||
var saved = ((str.length - result.code.length) / str.length * 100).toFixed(2);
|
var saved = ((str.length - result.code.length) / str.length * 100).toFixed(2);
|
||||||
if (options.logger) {
|
if (js_logger) {
|
||||||
var log = hexo.log || console.log;
|
var 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 + '%');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "hexo-yam",
|
"name": "hexo-yam",
|
||||||
"description": "Yet Another Minifier. Minify html, js and css",
|
"description": "Yet Another Minifier. Minify html, js and css",
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|
Loading…
Reference in New Issue