From 887eeda3cca787e245df6903f6ceaf97929058e7 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Wed, 9 Oct 2019 23:33:34 +0100 Subject: [PATCH] feat: add 'priority' options --- README.md | 6 ++++++ index.js | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a787a2f..44425ef 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ minify: 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. - **logger** - Verbose output. Defaults to `false`. - **exclude** - Exclude files. - Support one-liner, `exclude: [*.min.html, *.note.html]`. @@ -69,6 +70,7 @@ minify: - '*.min.css' ``` - **enable** - Enable the plugin. Defaults to `true`. +- **priority** - Plugin's priority. Defaults to `10`. - **logger** - Verbose output. Defaults to `false`. - **exclude** - Exclude files. Support wildcard pattern. - **level** - Optimization level. Defaults to `2`. @@ -86,6 +88,7 @@ minify: - '*.min.js' ``` - **enable** - Enable the plugin. Defaults to `true`. +- **priority** - Plugin's priority. Defaults to `10`. - **logger** - Verbose output. Defaults to `false`. - **exclude** - Exclude files. Support wildcard pattern. - **compress** - Compress options. @@ -107,6 +110,7 @@ minify: - '!*.min.svg' ``` - **enable** - Enable the plugin. Defaults to `true`. +- **priority** - Plugin's priority. Defaults to `10`. - **logger** - Verbose output. Defaults to `false`. - **include** - Include files. Support wildcard pattern. - Exclude `*.min.svg` by default. @@ -136,6 +140,7 @@ minify: - '*.json' ``` - **enable** - Enable the plugin. Defaults to `true`. +- **priority** - Plugin's priority. Defaults to `10`. - **logger** - Verbose output. Defaults to `false`. - **include** - Include files. Support wildcard pattern. - Support one-liner, `include: ['*.html','*.css','*.js']`. @@ -162,6 +167,7 @@ minify: - '*.json' ``` - **enable** - Enable the plugin. Defaults to `true`. +- **priority** - Plugin's priority. Defaults to `10`. - **logger** - Verbose output. Defaults to `false`. - **include** - Include files. Support wildcard pattern. - **globOptions** - See [`html:`](#options). diff --git a/index.js b/index.js index ce86359..4583aee 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ hexo.config.minify = Object.assign({ hexo.config.minify.html = Object.assign({ enable: true, + priority: 10, logger: false, exclude: [], collapseBooleanAttributes: true, @@ -24,6 +25,7 @@ hexo.config.minify.html = Object.assign({ hexo.config.minify.css = Object.assign({ enable: true, + priority: 10, // TODO: rename to verbose logger: false, exclude: ['*.min.css'], @@ -33,6 +35,7 @@ hexo.config.minify.css = Object.assign({ hexo.config.minify.js = Object.assign({ enable: true, + priority: 10, logger: false, exclude: ['*.min.js'], compress: {}, @@ -43,6 +46,7 @@ hexo.config.minify.js = Object.assign({ hexo.config.minify.svg = Object.assign({ enable: true, + priority: 10, logger: false, include: ['*.svg', '!*.min.svg'], plugins: [], @@ -51,6 +55,7 @@ hexo.config.minify.svg = Object.assign({ hexo.config.minify.gzip = Object.assign({ enable: true, + priority: 10, logger: false, include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'], globOptions: { basename: true } @@ -58,6 +63,7 @@ hexo.config.minify.gzip = Object.assign({ hexo.config.minify.brotli = Object.assign({ enable: true, + priority: 10, logger: false, include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'], globOptions: { basename: true } @@ -65,10 +71,10 @@ hexo.config.minify.brotli = Object.assign({ if (hexo.config.minify.enable === true) { const filter = require('./lib/filter') - hexo.extend.filter.register('after_render:html', filter.minifyHtml) - hexo.extend.filter.register('after_render:css', filter.minifyCss) - hexo.extend.filter.register('after_render:js', filter.minifyJs) - hexo.extend.filter.register('after_generate', filter.minifySvg) - hexo.extend.filter.register('after_generate', filter.gzipFn) - hexo.extend.filter.register('after_generate', filter.brotliFn) + 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) + hexo.extend.filter.register('after_render:js', filter.minifyJs, hexo.config.minify.js.priority) + hexo.extend.filter.register('after_generate', filter.minifySvg, hexo.config.minify.svg.priority) + hexo.extend.filter.register('after_generate', filter.gzipFn, hexo.config.minify.gzip.priority) + hexo.extend.filter.register('after_generate', filter.brotliFn, hexo.config.minify.brotli.priority) }