feat: allow custom options for neat_css

https://github.com/jakubpawlowicz/clean-css
This commit is contained in:
weyusi 2019-04-23 13:26:43 +09:30
parent b93e92b1bb
commit 94a8f90c2b
3 changed files with 5 additions and 1 deletions

View File

@ -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
----------

View File

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

View File

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