Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add plugin hexo-htmlnano-mini #2285

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions source/_data/plugins/hexo-htmlnano-mini.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
description: A lightweight Hexo plugin to minify HTML using htmlnano
link: https://github.com/RoversX/hexo-htmlnano-mini
tags:
- html
- htmlnano
- minify
- css
- js
Comment on lines +7 to +8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does hexo-htmlnano-mini will also work on css/js files?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I initially tested this on my blog and resolved several issues during the process.

It now supports HTML minification using htmlnano, CSS minification with clean-css, and JavaScript minification with uglify-js. Additionally, it’s compatible with the hexo-blog-encrypt plugin. The default packages, cssnano and Terser, had some issues, so I replaced them with clean-css and uglify-js from html-minifier.
https://github.com/RoversX/hexo-htmlnano-mini/blob/main/package.json

htmlnano-mini:
  enable: true                        # 主开关
  enableInDev: false                  # 是否在开发服务器(hexo s)中启用压缩
  exclude: 
     #- '**/mycss.css'       
  collapseWhitespace: conservative    # 保守地压缩空白字符
  removeComments: safe                # 安全地移除注释
  removeEmptyAttributes: true         # 移除空属性 
  cleancss: true                      # 启用 clean-css 处理 CSS
  uglifyjs: true                      # 启用JavaScript 的压缩

- optmize