Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support pre-compressed-assets #100

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

curbengh
Copy link
Contributor

@curbengh curbengh commented Oct 5, 2019

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
Copy link
Contributor Author

curbengh commented Oct 5, 2019

WIP, haven't add test case.

@coveralls
Copy link

coveralls commented Oct 5, 2019

Coverage Status

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

@coveralls
Copy link

Coverage Status

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

@SukkaW
Copy link
Member

SukkaW commented Oct 5, 2019

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.

@curbengh
Copy link
Contributor Author

curbengh commented Oct 5, 2019

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 curbengh force-pushed the pre-compressed branch 2 times, most recently from 275b510 to bf427b2 Compare November 17, 2019 01:36
@curbengh curbengh requested a review from a team November 17, 2019 01:38
@curbengh curbengh marked this pull request as ready for review November 17, 2019 01:38
@curbengh
Copy link
Contributor Author

Added test.

Comment on lines -40 to -42
extensions:
- html
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed as they are not the default. User can always refer to https://github.com/expressjs/serve-static#options.

@curbengh curbengh force-pushed the pre-compressed branch 2 times, most recently from 00dedba to 713ce74 Compare November 17, 2019 01:58
@curbengh curbengh requested review from a team and removed request for a team December 13, 2019 11:09
@curbengh curbengh requested review from a team and removed request for a team December 28, 2019 00:48
@curbengh
Copy link
Contributor Author

curbengh commented Dec 28, 2019

not compatible with #111 yet


fixed 40fe06d

@curbengh curbengh marked this pull request as draft June 27, 2020 10:53
@curbengh curbengh marked this pull request as ready for review July 29, 2020 10:30
@curbengh curbengh requested review from a team and removed request for a team July 31, 2020 08:14
@tomap
Copy link
Contributor

tomap commented Dec 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants