hexo-server
hexo-server copied to clipboard
feat: support pre-compressed-assets
Serve pre-compressed assets when found, else fallback to dynamic compression (when both compress
and pre_compressed
are enabled).
compress
is independent from pre_compressed
, so either one can be enabled.
Adapted from pre-compressed-assets middleware plus this fix, with es6 syntax and utilize hexo router (instead of node-glob).
WIP, haven't add test case.
Coverage decreased (-2.6%) to 92.771% when pulling 40fe06df25e5d914292e9dcd2743721d6dbf7948 on curbengh:pre-compressed into a146d2dcb9333be8409afd4f238824bb04daa722 on hexojs:master.
Coverage decreased (-3.8%) to 90.291% when pulling 36ce99ba669213c6ddc52beb3291efc4efacdaf5 on curbengh:pre-compressed into fc029327d359d051d1c137a0297e8dbafb61b192 on hexojs:master.
I don't see how pre-compressed files can be served in hexo-server. I mean, most of the theme doesn't provide pre-compressed js & css.
With a compression plugin like hexo-yam.
How to test:
package.json
- "hexo-server": "^1.0.0"
+ "hexo-server": "curbengh/hexo-server#pre-compressed",
+ "hexo-yam": "^3.1.0"
_config.yml
+server:
+ pre_compressed: true
$ rm -r node_modules/
$ npm i
$ hexo s
Check response header.
Added test.
not compatible with https://github.com/hexojs/hexo-server/pull/111 yet
fixed https://github.com/hexojs/hexo-server/pull/100/commits/40fe06df25e5d914292e9dcd2743721d6dbf7948
I would say that hexo-server is a debug server only, not a prod server. Should absolutely not be used to serve a site except for testing!
So in that context, really no need to have compression, pre compression, ....