hexo-server icon indicating copy to clipboard operation
hexo-server copied to clipboard

feat: support pre-compressed-assets

Open curbengh opened this issue 4 years ago • 8 comments

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).

curbengh avatar Oct 05 '19 03:10 curbengh

WIP, haven't add test case.

curbengh avatar Oct 05 '19 03:10 curbengh

Coverage Status

Coverage decreased (-2.6%) to 92.771% when pulling 40fe06df25e5d914292e9dcd2743721d6dbf7948 on curbengh:pre-compressed into a146d2dcb9333be8409afd4f238824bb04daa722 on hexojs:master.

coveralls avatar Oct 05 '19 03:10 coveralls

Coverage Status

Coverage decreased (-3.8%) to 90.291% when pulling 36ce99ba669213c6ddc52beb3291efc4efacdaf5 on curbengh:pre-compressed into fc029327d359d051d1c137a0297e8dbafb61b192 on hexojs:master.

coveralls avatar Oct 05 '19 03:10 coveralls

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.

SukkaW avatar Oct 05 '19 12:10 SukkaW

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.

curbengh avatar Oct 05 '19 13:10 curbengh

Added test.

curbengh avatar Nov 17 '19 01:11 curbengh

not compatible with https://github.com/hexojs/hexo-server/pull/111 yet


fixed https://github.com/hexojs/hexo-server/pull/100/commits/40fe06df25e5d914292e9dcd2743721d6dbf7948

curbengh avatar Dec 28 '19 06:12 curbengh

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, ....

tomap avatar Dec 01 '21 19:12 tomap