feat: add 'priority' options

This commit is contained in:
curbengh 2019-10-09 23:33:34 +01:00
parent 48bf9951f0
commit 887eeda3cc
No known key found for this signature in database
GPG Key ID: 21EA847C35D6E034
2 changed files with 18 additions and 6 deletions

View File

@ -49,6 +49,7 @@ minify:
exclude: exclude:
``` ```
- **enable** - Enable the plugin. Defaults to `true`. - **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`. - **logger** - Verbose output. Defaults to `false`.
- **exclude** - Exclude files. - **exclude** - Exclude files.
- Support one-liner, `exclude: [*.min.html, *.note.html]`. - Support one-liner, `exclude: [*.min.html, *.note.html]`.
@ -69,6 +70,7 @@ minify:
- '*.min.css' - '*.min.css'
``` ```
- **enable** - Enable the plugin. Defaults to `true`. - **enable** - Enable the plugin. Defaults to `true`.
- **priority** - Plugin's priority. Defaults to `10`.
- **logger** - Verbose output. Defaults to `false`. - **logger** - Verbose output. Defaults to `false`.
- **exclude** - Exclude files. Support wildcard pattern. - **exclude** - Exclude files. Support wildcard pattern.
- **level** - Optimization level. Defaults to `2`. - **level** - Optimization level. Defaults to `2`.
@ -86,6 +88,7 @@ minify:
- '*.min.js' - '*.min.js'
``` ```
- **enable** - Enable the plugin. Defaults to `true`. - **enable** - Enable the plugin. Defaults to `true`.
- **priority** - Plugin's priority. Defaults to `10`.
- **logger** - Verbose output. Defaults to `false`. - **logger** - Verbose output. Defaults to `false`.
- **exclude** - Exclude files. Support wildcard pattern. - **exclude** - Exclude files. Support wildcard pattern.
- **compress** - Compress options. - **compress** - Compress options.
@ -107,6 +110,7 @@ minify:
- '!*.min.svg' - '!*.min.svg'
``` ```
- **enable** - Enable the plugin. Defaults to `true`. - **enable** - Enable the plugin. Defaults to `true`.
- **priority** - Plugin's priority. Defaults to `10`.
- **logger** - Verbose output. Defaults to `false`. - **logger** - Verbose output. Defaults to `false`.
- **include** - Include files. Support wildcard pattern. - **include** - Include files. Support wildcard pattern.
- Exclude `*.min.svg` by default. - Exclude `*.min.svg` by default.
@ -136,6 +140,7 @@ minify:
- '*.json' - '*.json'
``` ```
- **enable** - Enable the plugin. Defaults to `true`. - **enable** - Enable the plugin. Defaults to `true`.
- **priority** - Plugin's priority. Defaults to `10`.
- **logger** - Verbose output. Defaults to `false`. - **logger** - Verbose output. Defaults to `false`.
- **include** - Include files. Support wildcard pattern. - **include** - Include files. Support wildcard pattern.
- Support one-liner, `include: ['*.html','*.css','*.js']`. - Support one-liner, `include: ['*.html','*.css','*.js']`.
@ -162,6 +167,7 @@ minify:
- '*.json' - '*.json'
``` ```
- **enable** - Enable the plugin. Defaults to `true`. - **enable** - Enable the plugin. Defaults to `true`.
- **priority** - Plugin's priority. Defaults to `10`.
- **logger** - Verbose output. Defaults to `false`. - **logger** - Verbose output. Defaults to `false`.
- **include** - Include files. Support wildcard pattern. - **include** - Include files. Support wildcard pattern.
- **globOptions** - See [`html:`](#options). - **globOptions** - See [`html:`](#options).

View File

@ -7,6 +7,7 @@ hexo.config.minify = Object.assign({
hexo.config.minify.html = Object.assign({ hexo.config.minify.html = Object.assign({
enable: true, enable: true,
priority: 10,
logger: false, logger: false,
exclude: [], exclude: [],
collapseBooleanAttributes: true, collapseBooleanAttributes: true,
@ -24,6 +25,7 @@ hexo.config.minify.html = Object.assign({
hexo.config.minify.css = Object.assign({ hexo.config.minify.css = Object.assign({
enable: true, enable: true,
priority: 10,
// TODO: rename to verbose // TODO: rename to verbose
logger: false, logger: false,
exclude: ['*.min.css'], exclude: ['*.min.css'],
@ -33,6 +35,7 @@ hexo.config.minify.css = Object.assign({
hexo.config.minify.js = Object.assign({ hexo.config.minify.js = Object.assign({
enable: true, enable: true,
priority: 10,
logger: false, logger: false,
exclude: ['*.min.js'], exclude: ['*.min.js'],
compress: {}, compress: {},
@ -43,6 +46,7 @@ hexo.config.minify.js = Object.assign({
hexo.config.minify.svg = Object.assign({ hexo.config.minify.svg = Object.assign({
enable: true, enable: true,
priority: 10,
logger: false, logger: false,
include: ['*.svg', '!*.min.svg'], include: ['*.svg', '!*.min.svg'],
plugins: [], plugins: [],
@ -51,6 +55,7 @@ hexo.config.minify.svg = Object.assign({
hexo.config.minify.gzip = Object.assign({ hexo.config.minify.gzip = Object.assign({
enable: true, enable: true,
priority: 10,
logger: false, logger: false,
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'], include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
globOptions: { basename: true } globOptions: { basename: true }
@ -58,6 +63,7 @@ hexo.config.minify.gzip = Object.assign({
hexo.config.minify.brotli = Object.assign({ hexo.config.minify.brotli = Object.assign({
enable: true, enable: true,
priority: 10,
logger: false, logger: false,
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'], include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
globOptions: { basename: true } globOptions: { basename: true }
@ -65,10 +71,10 @@ hexo.config.minify.brotli = Object.assign({
if (hexo.config.minify.enable === true) { if (hexo.config.minify.enable === true) {
const filter = require('./lib/filter') const filter = require('./lib/filter')
hexo.extend.filter.register('after_render:html', filter.minifyHtml) hexo.extend.filter.register('after_render:html', filter.minifyHtml, hexo.config.minify.html.priority)
hexo.extend.filter.register('after_render:css', filter.minifyCss) hexo.extend.filter.register('after_render:css', filter.minifyCss, hexo.config.minify.css.priority)
hexo.extend.filter.register('after_render:js', filter.minifyJs) hexo.extend.filter.register('after_render:js', filter.minifyJs, hexo.config.minify.js.priority)
hexo.extend.filter.register('after_generate', filter.minifySvg) hexo.extend.filter.register('after_generate', filter.minifySvg, hexo.config.minify.svg.priority)
hexo.extend.filter.register('after_generate', filter.gzipFn) hexo.extend.filter.register('after_generate', filter.gzipFn, hexo.config.minify.gzip.priority)
hexo.extend.filter.register('after_generate', filter.brotliFn) hexo.extend.filter.register('after_generate', filter.brotliFn, hexo.config.minify.brotli.priority)
} }