mirror of https://github.com/curbengh/hexo-yam
Merge pull request #157 from curbengh/previewServer
feat: previewServer option
This commit is contained in:
commit
7639547408
|
@ -35,6 +35,7 @@ $ npm install hexo-yam --save
|
|||
``` yaml
|
||||
minify:
|
||||
enable: true
|
||||
previewServer: true
|
||||
html:
|
||||
css:
|
||||
js:
|
||||
|
@ -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
|
||||
|
|
5
index.js
5
index.js
|
@ -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({
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue