Skip to content

Commit

Permalink
Merge pull request #157 from curbengh/previewServer
Browse files Browse the repository at this point in the history
feat: previewServer option
  • Loading branch information
curbengh committed Jun 7, 2024
2 parents f7df263 + e9584b2 commit 7639547
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ $ npm install hexo-yam --save
``` yaml
minify:
enable: true
previewServer: true
html:
css:
js:
Expand All @@ -46,6 +47,7 @@ minify:
```

- **enable** - Enable the plugin. Defaults to `true`.
- **previewServer** - Disable the plugin when running `hexo server`. Defaults to `true`.
- **html** - See [HTML](#html) section
- **css** - See [CSS](#css) section
- **js** - See [JS](#js) section
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
'use strict'

hexo.config.minify = Object.assign({
enable: true
enable: true,
previewServer: true
}, hexo.config.minify)

hexo.config.minify.html = Object.assign({
Expand Down Expand Up @@ -93,7 +94,7 @@ hexo.config.minify.json = Object.assign({
globOptions: { basename: true }
}, hexo.config.minify.json)

if (hexo.config.minify.enable === true) {
if (hexo.config.minify.enable === true && !(hexo.config.minify.previewServer === true && ['s', 'server'].includes(hexo.env.cmd))) {
const filter = require('./lib/filter')
hexo.extend.filter.register('after_render:html', filter.minifyHtml, hexo.config.minify.html.priority)
hexo.extend.filter.register('after_render:css', filter.minifyCss, hexo.config.minify.css.priority)
Expand Down

0 comments on commit 7639547

Please sign in to comment.