Open Buzut opened 4 years ago
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
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.
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?