Go to file
dependabot[bot] 9c8a228e09
chore(deps): bump svgo from 2.8.0 to 3.0.0
Bumps [svgo](https://github.com/svg/svgo) from 2.8.0 to 3.0.0.
- [Release notes](https://github.com/svg/svgo/releases)
- [Changelog](https://github.com/svg/svgo/blob/main/CHANGELOG-old.md)
- [Commits](https://github.com/svg/svgo/compare/v2.8.0...v3.0.0)

---
updated-dependencies:
- dependency-name: svgo
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-06 02:58:07 +00:00
.github ci(tester): add node 19 2022-11-05 02:02:16 +00:00
lib fix(svg): compatibility with svgo 2.4+ 2021-10-10 09:19:50 +00:00
test fix(svg): compatibility with svgo 2.4+ 2021-10-10 09:19:50 +00:00
.gitignore test: add tests for html, js, css minifiers 2019-12-26 13:19:39 +00:00
.npmrc chore: ignore optional deps 2019-06-22 14:22:08 +09:30
.snyk chore(snyk): remove old policy 2022-05-13 00:50:47 +00:00
LICENSE chore: update username 2019-07-18 17:34:26 +09:30
README.md docs: cleanup previous config changes 2022-05-06 06:21:15 +00:00
index.js fix(svg): compatibility with svgo 2.4+ 2021-10-10 09:19:50 +00:00
package.json chore(deps): bump svgo from 2.8.0 to 3.0.0 2022-11-06 02:58:07 +00:00

README.md

hexo-yam

npm version Build Status codecov NPM Dependencies Known Vulnerabilities Total alerts Language grade: JavaScript

Yet Another Minifier for Hexo. Minify and compress HTML, JS, CSS, SVG, XML and JSON. Other files are also compressed. Support gzip and brotli compressions.

Table of contents

Installation

$ npm install hexo-yam --save

Options

minify:
  enable: true
  html:
  css:
  js:
  svg:
  gzip:
  brotli:
  xml:
  json:
  • enable - Enable the plugin. Defaults to true.
  • html - See HTML section
  • css - See CSS section
  • js - See JS section
  • svg - See SVG section
  • gzip - See Gzip section
  • brotli - See Brotli section
  • xml - See XML section
  • json - See JSON section

HTML

minify:
  html:
    enable: true
    exclude:
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10. Set lower value to set higher priority and vice versa.
  • verbose - Verbose output. Defaults to false.
  • exclude - Exclude files. Support wildcard pattern(s) in a string or array.
  • globOptions - See globbing section.

For more options, see HTMLMinifier.

CSS

minify:
  css:
    enable: true
    exclude:
      - '*.min.css'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • exclude - Exclude files. Support wildcard pattern(s) in a string or array.
  • level - Optimization level. Defaults to 2.
  • globOptions - See globbing section.

For more options, see clean-css.

JS

minify:
  js:
    enable: true
    exclude:
      - '*.min.js'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • exclude - Exclude files. Support wildcard pattern(s) in a string or array.
  • compress - Compress options.
  • mangle - Mangle variable names. Defaults to true. Pass an object to specify mangle options.
  • output - Output options.
    • To retain comments, output: {comments: true}.
  • globOptions - See globbing section.

For more options, see Terser.

SVG

minify:
  svg:
    enable: true
    include:
      - '*.svg'
      - '!*.min.svg'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
    • Exclude *.min.svg by default.
  • plugins - Plugin options.
    • Examples:
    plugins:
      # Retain comments
      removeComments: false
      # Do not remove unused ID attributes
      cleanupIDs: false
    
    • For more options, see svgo.
  • globOptions - See globbing section.

Gzip

minify:
  gzip:
    enable: true
    include:
      - '*.html'
      - '*.css'
      - '*.js'
      - '*.txt'
      - '*.ttf'
      - '*.atom'
      - '*.stl'
      - '*.xml'
      - '*.svg'
      - '*.eot'
      - '*.json'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
    • Support one-liner, include: ['*.html','*.css','*.js'].
    • Must include asterisk and single quotes. .html is invalid. '*.html' is valid.
  • globOptions - See globbing section.
  • 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

Brotli

minify:
  brotli:
    enable: true
    include:
      - '*.html'
      - '*.css'
      - '*.js'
      - '*.txt'
      - '*.ttf'
      - '*.atom'
      - '*.stl'
      - '*.xml'
      - '*.svg'
      - '*.eot'
      - '*.json'
  • enable - Enable the plugin. Defaults to true.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
  • globOptions - See globbing section.
  • level - Compression level. Range 1-11. Defaults to 11, or the value of zlib.constants.BROTLI_MAX_QUALITY

XML

Remove whitespaces in xml.

minify:
  xml:
    enable: false
    include:
      - '*.xml'
      - '!*.min.xml'
  • enable - Enable the plugin. Defaults to false.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
    • Exclude *.min.xml by default.
  • removeComments - Remove comments in xml. Defaults to true.
  • globOptions - See globbing section.

For more options, see minify-xml.

JSON

Remove whitespaces in json.

minify:
  json:
    enable: false
    include:
      - '*.json'
      - '!*.min.json'
  • enable - Enable the plugin. Defaults to false.
  • priority - Plugin's priority. Defaults to 10.
  • verbose - Verbose output. Defaults to false.
  • include - Include files. Support wildcard pattern(s) in a string or array.
    • Exclude *.min.json by default.
  • globOptions - See globbing section.

Globbing

Use "globOptions" to customise how glob patterns match files. Refer to micromatch for available options.

  • basename is enabled by default, unless the pattern has a slash.
  • basename is disabled depending on each pattern.
  • This means the following options would work,
exclude:
  - '*foo.html' # basename is enabled
  - '**/bar/*/*.html' # basename is automatically disabled
  - '*baz.css' # basename is enabled
globOptions:
  basename: true # default
  • This behaviour doesn't apply to pattern that starts with ! (negation).
  • This limitation only applies to include: option used in svg, gzip and brotli.
  • This means the following options would not work,
include:
  - '!foo.svg'
  - '!**/bar/*/*.svg'
globOptions:
  basename: true
  • basename will stay disabled, if explicitly disabled in "globOptions".

HTTP Compression

While most modern web browsers support Brotli, you also need to consider whether the web/app server, hosting platform, reverse proxy or CDN (whichever relevant to you) support it.

Brotli support as of May 2022:

Name Brotli support
GitHub Pages In consideration
GitLab Pages Yes
Netlify Yes
Hexo Server In progress

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),

  • Caddy: 0.9.4+ by default support pre-compressed .gz .br files and on-the-fly gzip compress dynamic files. v2.4.0+ requires specifying the precompressed option.
  • nginx: Make sure both filter and static modules are enabled. This way pre-compressed .br files will be served while dynamic content can be compressed on-the-fly. Protip: brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss; to prevent compressing media files (which are already compressed anyway).
  • Apache: See 'Serving pre-compressed content' section of mod_brotli.
  • express/connect: Use pre-compressed-assets. You still can continue to use compression/shrink-ray-current for dynamic files.

Credits

All credits go to the following work: