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

Option to disable compression when using hexo server #22

Open
Buzut opened this issue May 6, 2020 · 2 comments
Open

Option to disable compression when using hexo server #22

Buzut opened this issue May 6, 2020 · 2 comments

Comments

@Buzut
Copy link

Buzut commented May 6, 2020

As when using Hexo server we often seek for speed over everything, it could be a really nice option to be able to disable compression when using the local webserver (watch mode).

What do you think about it?

@curbengh
Copy link
Owner

curbengh commented May 7, 2020

Actually this is also an issue for me. As a workaround, I use a script to inject minify: false (to _config.yml) before executing hexo server and restore when server quits.

I put the script in ~/.local/bin/hexo-server. When I execute just $ hexo-server, hexo-yam is enabled, and $ hexo-server test will disable hexo-yam.

Perhaps there is a way to detect hexo generate and hexo server from this plugin and disable itself automatically, I haven't quite dig deep into this yet.

This is the script I use, it also disables hexo-filter-nofollow.

#!/bin/sh

ARG=$1

## Clean hexo database, enable hexo_nofollow and hexo_yam before ctrl+c and exit
trap cleanup 0 1 2 3 6 15
cleanup() {
  if [ -n "$ARG" ]; then
    sed -z -i "s/\nnofollow:\n  enable: false//" _config.yml
    sed -z -i "s/minify:\n  enable: false/minify:/" _config.yml
  fi
  hexo clean
}

if [ -n "$1" ]; then
  ## Disable hexo_nofollow
  printf "\nnofollow:\n  enable: false" >> _config.yml

  ## Disable hexo_yam
  sed -z -i "s/minify:/minify:\n  enable: false/" _config.yml
fi

## Run hexo server on localhost
hexo clean
hexo server

@Buzut
Copy link
Author

Buzut commented May 20, 2020

That could help, thanks!
I've found that there actually is an env variable that can tell whether we are in dev (hexo serve) or prod (hexo build) mode.

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

No branches or pull requests

2 participants