From 94a8f90c2b11566229c27ec9306654dfb246a9fc Mon Sep 17 00:00:00 2001 From: weyusi Date: Tue, 23 Apr 2019 13:26:43 +0930 Subject: [PATCH] feat: allow custom options for neat_css https://github.com/jakubpawlowicz/clean-css --- README.md | 3 +++ index.js | 1 + lib/filter.js | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f77bc0..67f0ec5 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ neat_css: - **enable** - Enable the plugin. Defaults to `true`. - **logger** - Verbose output. Defaults to `false`. - **exclude** - Exclude files. Support wildcard pattern. +- **level** - Optimization level. Defaults to `2`. + +For more options, see ---------- diff --git a/index.js b/index.js index b53541f..4334bf0 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,7 @@ if (hexo.config.neat_enable === true) { hexo.config.neat_css = Object.assign({ enable: true, logger: false, + level: 2, exclude: ['*.min.css'] }, hexo.config.neat_css) diff --git a/lib/filter.js b/lib/filter.js index 872c281..f5f03fb 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -45,7 +45,7 @@ function logicCss (str, data) { } return new Promise(function (resolve, reject) { - new CleanCSS({ level: 2 }).minify(str, function (err, result) { + new CleanCSS(options).minify(str, function (err, result) { if (err) return reject(err) let saved = ((str.length - result.styles.length) / str.length * 100).toFixed(2) resolve(result.styles)