From 374c16575b45cb1d81d4c8037d278e553eed751b Mon Sep 17 00:00:00 2001 From: weyusi Date: Tue, 23 Apr 2019 17:46:56 +0930 Subject: [PATCH] style: rearrange and give more neat_js config examples --- README.md | 5 +++-- index.js | 8 ++++---- lib/filter.js | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ad9e215..5e23717 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,10 @@ neat_js: - **enable** - Enable the plugin. Defaults to `true`. - **logger** - Verbose output. Defaults to `false`. - **exclude** - Exclude files. Support wildcard pattern. -- **mangle** - Mangle file names. Defaults to `true`. -- **output** - Output options. - **compress** - Compress options. +- **mangle** - Mangle variable names. Defaults to `true`. Pass an object to specify [mangle options](https://github.com/terser-js/terser#mangle-options). +- **output** - Output options. + - To retain comments, `output: {comments: true}`. For more options, see [Terser](https://github.com/terser-js/terser). diff --git a/index.js b/index.js index e861da3..a4d7794 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,7 @@ if (hexo.config.neat_enable === true) { minifyCSS: true }, hexo.config.neat_html) - // Css minifier + // CSS minifier hexo.config.neat_css = Object.assign({ enable: true, logger: false, @@ -23,14 +23,14 @@ if (hexo.config.neat_enable === true) { level: 2 }, hexo.config.neat_css) - // Js minifier + // Javascript minifier hexo.config.neat_js = Object.assign({ enable: true, logger: false, exclude: ['*.min.js'], + compress: {}, mangle: true, - output: {}, - compress: {} + output: {} }, hexo.config.neat_js) // SVG minifier diff --git a/lib/filter.js b/lib/filter.js index 4b5557f..0c5cf78 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -1,12 +1,12 @@ /* global hexo */ 'use strict' +const Htmlminifier = require('html-minifier').minify const CleanCSS = require('clean-css') const Terser = require('terser') -const Htmlminifier = require('html-minifier').minify -const nanomatch = require('nanomatch') +const svgo = require('svgo') const zlib = require('zlib') const br = require('iltorb') -const svgo = require('svgo') +const nanomatch = require('nanomatch') function logicHtml (str, data) { const hexo = this