mirror of https://github.com/curbengh/hexo-yam
docs: 'logger:', compression level, 'basename' globOptions
This commit is contained in:
parent
7201b3f56f
commit
6111d21a7c
47
README.md
47
README.md
|
@ -8,22 +8,23 @@
|
|||
|
||||
Yet Another Minifier for Hexo. Minify and compress HTML, JS, CSS and SVG. XML, JSON and [many more](https://github.com/curbengh/hexo-yam/blob/ba77db0094a7c07ea9f70f010bfc15541d4105ca/index.js#L64) are also compressed. Support gzip and [brotli](https://en.wikipedia.org/wiki/Brotli) [compressions](https://en.wikipedia.org/wiki/HTTP_compression).
|
||||
|
||||
## Version 3
|
||||
In v3 onwards, this plugin is enabled by default. Most [options](#options) have changed and they are now under `minify:` option.
|
||||
## Version 4
|
||||
In v4, `logger:` option has been renamed to `verbose:`
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
neat_svg:
|
||||
plugins: [{cleanupIDs: false}]
|
||||
``` yml
|
||||
minify:
|
||||
html:
|
||||
logger: true
|
||||
```
|
||||
|
||||
needs to be updated to
|
||||
|
||||
```
|
||||
``` yml
|
||||
minify:
|
||||
svg:
|
||||
plugins: [{cleanupIDs: false}]
|
||||
html:
|
||||
verbose: true
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
@ -50,13 +51,16 @@ minify:
|
|||
```
|
||||
- **enable** - Enable the plugin. Defaults to `true`.
|
||||
- **priority** - Plugin's priority. Defaults to `10`. Set lower value to set higher priority and vice versa.
|
||||
- **logger** - Verbose output. Defaults to `false`.
|
||||
- **verbose** - Verbose output. Defaults to `false`.
|
||||
- **exclude** - Exclude files.
|
||||
- Support one-liner, `exclude: [*.min.html, *.note.html]`.
|
||||
- To exclude a file, double asterisk and the full path must be specified, `**/themes/typing/source/js/source.js`.
|
||||
- `*source.js` also works, but it also excludes `resource.js`.
|
||||
- Test glob pattern on the web using [Globtester](http://www.globtester.com/).
|
||||
- **globOptions** - [micromatch options](https://github.com/micromatch/micromatch#options) to customise how glob patterns match files. Defaults to `{ basename: true }`, unless the pattern has a slash.
|
||||
- **globOptions** - [micromatch options](https://github.com/micromatch/micromatch#options) to customise how glob patterns match files.
|
||||
- Defaults to `{ basename: true }`, unless the pattern has a slash.
|
||||
- basename is disabled depending on each pattern.
|
||||
- When specifying an array of patterns, e.g. `exclude: ['*foo.html', '**/bar.html']`, basename applies to `'*foo.html'`, but not `'**/bar.html'`.
|
||||
- basename would stay disabled, if explicitly disabled in `globOptions:`.
|
||||
- However, basename option applies to all patterns in `include:`
|
||||
|
||||
For more options, see [HTMLMinifier](https://github.com/kangax/html-minifier).
|
||||
|
||||
|
@ -71,7 +75,7 @@ minify:
|
|||
```
|
||||
- **enable** - Enable the plugin. Defaults to `true`.
|
||||
- **priority** - Plugin's priority. Defaults to `10`.
|
||||
- **logger** - Verbose output. Defaults to `false`.
|
||||
- **verbose** - Verbose output. Defaults to `false`.
|
||||
- **exclude** - Exclude files. Support wildcard pattern.
|
||||
- **level** - Optimization level. Defaults to `2`.
|
||||
- **globOptions** - See [`html:`](#options).
|
||||
|
@ -89,7 +93,7 @@ minify:
|
|||
```
|
||||
- **enable** - Enable the plugin. Defaults to `true`.
|
||||
- **priority** - Plugin's priority. Defaults to `10`.
|
||||
- **logger** - Verbose output. Defaults to `false`.
|
||||
- **verbose** - Verbose output. Defaults to `false`.
|
||||
- **exclude** - Exclude files. Support wildcard pattern.
|
||||
- **compress** - Compress options.
|
||||
- **mangle** - Mangle variable names. Defaults to `true`. Pass an object to specify [mangle options](https://github.com/terser-js/terser#mangle-options).
|
||||
|
@ -111,15 +115,14 @@ minify:
|
|||
```
|
||||
- **enable** - Enable the plugin. Defaults to `true`.
|
||||
- **priority** - Plugin's priority. Defaults to `10`.
|
||||
- **logger** - Verbose output. Defaults to `false`.
|
||||
- **verbose** - Verbose output. Defaults to `false`.
|
||||
- **include** - Include files. Support wildcard pattern.
|
||||
- Exclude `*.min.svg` by default.
|
||||
- **plugins** - Plugin options.
|
||||
- To retain comments, `plugins: [{removeComments: false}]`.
|
||||
- For more options, see [svgo](https://github.com/svg/svgo).
|
||||
- **globOptions** - See [`html:`](#options).
|
||||
|
||||
For more options, see [svgo](https://github.com/svg/svgo).
|
||||
|
||||
---
|
||||
|
||||
``` yaml
|
||||
|
@ -141,11 +144,12 @@ minify:
|
|||
```
|
||||
- **enable** - Enable the plugin. Defaults to `true`.
|
||||
- **priority** - Plugin's priority. Defaults to `10`.
|
||||
- **logger** - Verbose output. Defaults to `false`.
|
||||
- **verbose** - Verbose output. Defaults to `false`.
|
||||
- **include** - Include files. Support wildcard pattern.
|
||||
- Support one-liner, `include: ['*.html','*.css','*.js']`.
|
||||
- Must include asterisk and single quotes. `.html` is invalid. `'*.html'` is valid.
|
||||
- **globOptions** - See [`html:`](#options).
|
||||
- **level** - Compression level; lower value may results in faster compression but slightly larger (compressed) file. Range `1-9`. Defaults to `9`, or the value of [`zlib.constants.Z_BEST_COMPRESSION`](https://nodejs.org/docs/latest-v12.x/api/zlib.html#zlib_zlib_constants)
|
||||
|
||||
---
|
||||
|
||||
|
@ -168,9 +172,10 @@ minify:
|
|||
```
|
||||
- **enable** - Enable the plugin. Defaults to `true`.
|
||||
- **priority** - Plugin's priority. Defaults to `10`.
|
||||
- **logger** - Verbose output. Defaults to `false`.
|
||||
- **verbose** - Verbose output. Defaults to `false`.
|
||||
- **include** - Include files. Support wildcard pattern.
|
||||
- **globOptions** - See [`html:`](#options).
|
||||
- **level** - Compression level. Range `1-11`. Defaults to `11`, or the value of [`zlib.constants.BROTLI_MAX_QUALITY`](https://nodejs.org/docs/latest-v12.x/api/zlib.html#zlib_brotli_constants)
|
||||
|
||||
## HTTP Compression
|
||||
While most modern web browsers [support Brotli](https://www.caniuse.com/#feat=brotli), you also need to consider whether the web/app server, hosting platform, reverse proxy or CDN (whichever relevant to you) support it.
|
||||
|
@ -182,6 +187,7 @@ Name | Status (May 8, 2019)
|
|||
GitHub Pages | [In consideration](https://github.community/t5/GitHub-Pages/Support-for-pre-compressed-assets-and-brotli-compression/m-p/22055)
|
||||
GitLab Pages | [In progress](https://gitlab.com/gitlab-org/gitlab-pages/merge_requests/120)
|
||||
Netlify | [In consideration](https://postimg.cc/qgxn0261)
|
||||
Hexo Server | [In progress](https://github.com/hexojs/hexo-server/pull/100)
|
||||
|
||||
If you have access to the web server config, you should disable on-the-fly compression for static files (that are already compressed by this plugin),
|
||||
|
||||
|
@ -193,7 +199,4 @@ If you have access to the web server config, you should disable on-the-fly compr
|
|||
## Credits
|
||||
All credits go to the following work:
|
||||
- [hexo-neat](https://github.com/rozbo/hexo-neat) by rozbo
|
||||
- neat html by [HTMLMinifier](https://github.com/kangax/html-minifier)
|
||||
- neat css by [clean-css](https://github.com/jakubpawlowicz/clean-css)
|
||||
- neat js by [terser](https://github.com/terser-js/terser)
|
||||
- gzip feature is inspired by [hexo-generator-optimize](https://github.com/JackyRen/hexo-generator-optimize)
|
||||
|
|
Loading…
Reference in New Issue