chenzhutian / hexo-all-minifier

A plugin for Hexo that optimizes HTML, CSS, JS and imagages, and it can optionally deploys your blog.
MIT License
279 stars 30 forks source link

html中的exclude应该怎么设置才能自动压缩html #8

Closed caoji2001 closed 7 years ago

caoji2001 commented 8 years ago

按照readme中的设置,发现html并不会自动压缩,不知道是不是exclude没设置的原因

chenzhutian commented 8 years ago

最近hexo升级了新版本,然后有个bug,会编译不了 我之前去查了issue发现还没fix,不知道现在好了没有,我再跟进

Cat7373 commented 8 years ago

简单调试了下,看起来 OptimizeHTML 好像根本就没有执行的样子。

Cat7373 commented 8 years ago

https://github.com/hexojs/hexo/blob/master/lib/extend/filter.js#L58 我在这里加了一行调试代码:

console.log('#### Debug #### Call exec', type, data, options);

发现输出的内容里根本找不到<html

Cat7373 commented 8 years ago

感觉现在好像没法拿到完整 html 了- -

chenzhutian commented 8 years ago

@Cat7373 你的node的版本和all-minifier的版本是? 我最近update了一下,在es6下应该没问题

Cat7373 commented 8 years ago

今早用下面的命令安装测试的

npm install hexo-all-minifier --save

环境:Windows 10 64bit+Git v2.8.3+NodeJS v6.2.1+Hexo v3.2.0 测试方式:hexo server

Cat7373 commented 8 years ago

看了一下,这么安装后的版本是"hexo-all-minifier": "0.0.14",

Cat7373 commented 8 years ago

调用了下hexo clean,发现可以出现html压缩输出了,不过hexo server打开的网页中的html仍然没有压缩。 hexo g的输出结果也没有压缩

INFO  update Optimize HTML: E:\Blog\Hexo\source\_posts\github-hexo.md [ 1.02% saved]
INFO  update Optimize HTML: E:\Blog\Hexo\source\_posts\hexo-test.md [ 31.79% saved]
INFO  update Optimize HTML: E:\Blog\Hexo\source\tags\index.md [ NaN% saved]
INFO  update Optimize HTML: E:\Blog\Hexo\source\categories\index.md [ NaN% saved]
Cat7373 commented 8 years ago

网页中仍然有大量的空格与空行

chenzhutian commented 8 years ago

@Cat7373 不错我的环境跟你几乎是一样的,我也喜欢把所有版本都升到最新 我今晚来修一下

Cat7373 commented 8 years ago

并不是升级到最新- - 我是最近才刚入这个坑- - Git我是一直用常更新- - NodeJS``Hexo是前几天才下载的0.0 之前在用gulp来压缩代码的:https://zoakerc.com/archives/minify-static-resources-in-hexo-by-gulp-plugins/

chenzhutian commented 8 years ago

至少你是win10不是mac os…

chenzhutian commented 8 years ago

经测试发现是theme自带的html没法压缩,md渲染出来的html可以压缩。 这个好像是hexo触发事件的问题,暂时还没找到work around的方法

Cat7373 commented 8 years ago

我用的 NexT 主题- -

chenzhutian commented 8 years ago

就是after_render:html触发的函数只会传入md渲染出来的html,theme的模板html不会传入进去...

b1ngx commented 8 years ago

调试了下 OptimizeHTML 没有执行

b1ngx commented 8 years ago

应该是官方已经修复了这个,hexo 版本 3.2.2

chenzhutian commented 8 years ago

@sumjur 好的,过一段时间如果没有别的情况我就close这个issue了