2016-05-26 11:09:41 +00:00
|
|
|
/* global hexo */
|
2019-05-27 01:14:04 +00:00
|
|
|
'use strict'
|
|
|
|
|
2018-10-25 09:35:59 +00:00
|
|
|
if (hexo.config.neat_enable === true) {
|
|
|
|
// HTML minifier
|
2018-10-27 08:08:12 +00:00
|
|
|
hexo.config.neat_html = Object.assign({
|
2018-10-25 09:35:59 +00:00
|
|
|
enable: true,
|
2018-10-25 09:45:26 +00:00
|
|
|
logger: false,
|
2018-10-25 09:35:59 +00:00
|
|
|
exclude: [],
|
|
|
|
collapseBooleanAttributes: true,
|
2019-05-18 07:31:15 +00:00
|
|
|
collapseWhitespace: true,
|
2019-06-08 07:52:40 +00:00
|
|
|
// Ignore '<!-- more -->' https://hexo.io/docs/tag-plugins#Post-Excerpt
|
|
|
|
ignoreCustomComments: [/^\s*more/],
|
2019-05-18 07:31:15 +00:00
|
|
|
removeComments: true,
|
2018-10-25 09:35:59 +00:00
|
|
|
removeEmptyAttributes: true,
|
2019-05-18 07:31:15 +00:00
|
|
|
removeScriptTypeAttributes: true,
|
|
|
|
removeStyleLinkTypeAttributes: true,
|
2018-10-25 09:35:59 +00:00
|
|
|
minifyJS: true,
|
2019-07-10 02:20:23 +00:00
|
|
|
minifyCSS: true,
|
2019-08-06 01:53:58 +00:00
|
|
|
globOptions: { basename: true }
|
2018-10-25 09:35:59 +00:00
|
|
|
}, hexo.config.neat_html)
|
2016-05-26 11:09:41 +00:00
|
|
|
|
2019-04-23 08:16:56 +00:00
|
|
|
// CSS minifier
|
2018-10-27 08:08:12 +00:00
|
|
|
hexo.config.neat_css = Object.assign({
|
2018-10-25 09:35:59 +00:00
|
|
|
enable: true,
|
2018-10-25 09:45:26 +00:00
|
|
|
logger: false,
|
2019-04-23 04:01:04 +00:00
|
|
|
exclude: ['*.min.css'],
|
2019-07-10 02:20:23 +00:00
|
|
|
level: 2,
|
2019-08-06 01:53:58 +00:00
|
|
|
globOptions: { basename: true }
|
2018-10-25 09:35:59 +00:00
|
|
|
}, hexo.config.neat_css)
|
2016-05-26 11:09:41 +00:00
|
|
|
|
2019-04-23 08:16:56 +00:00
|
|
|
// Javascript minifier
|
2018-10-27 08:08:12 +00:00
|
|
|
hexo.config.neat_js = Object.assign({
|
2018-10-25 09:35:59 +00:00
|
|
|
enable: true,
|
2018-10-25 09:45:26 +00:00
|
|
|
logger: false,
|
2019-04-23 04:01:04 +00:00
|
|
|
exclude: ['*.min.js'],
|
2019-04-23 08:16:56 +00:00
|
|
|
compress: {},
|
2019-04-23 04:01:04 +00:00
|
|
|
mangle: true,
|
2019-07-10 02:20:23 +00:00
|
|
|
output: {},
|
2019-08-06 01:53:58 +00:00
|
|
|
globOptions: { basename: true }
|
2018-10-25 09:35:59 +00:00
|
|
|
}, hexo.config.neat_js)
|
2016-05-26 11:09:41 +00:00
|
|
|
|
2019-04-23 07:59:35 +00:00
|
|
|
// SVG minifier
|
|
|
|
hexo.config.neat_svg = Object.assign({
|
|
|
|
enable: true,
|
|
|
|
logger: false,
|
2019-05-02 06:25:43 +00:00
|
|
|
include: ['*.svg', '!*.min.svg'],
|
2019-07-10 02:20:23 +00:00
|
|
|
plugins: [],
|
2019-08-06 01:53:58 +00:00
|
|
|
globOptions: { basename: true }
|
2019-04-23 07:59:35 +00:00
|
|
|
}, hexo.config.neat_svg)
|
|
|
|
|
2019-04-23 05:40:43 +00:00
|
|
|
// gzip compression
|
2018-10-27 08:08:12 +00:00
|
|
|
hexo.config.neat_gzip = Object.assign({
|
2018-10-25 09:35:59 +00:00
|
|
|
enable: true,
|
2019-04-23 05:40:43 +00:00
|
|
|
logger: false,
|
2019-07-10 02:20:23 +00:00
|
|
|
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
|
2019-08-06 01:53:58 +00:00
|
|
|
globOptions: { basename: true }
|
2018-10-25 09:35:59 +00:00
|
|
|
}, hexo.config.neat_gzip)
|
2016-05-26 11:09:41 +00:00
|
|
|
|
2019-04-23 05:40:43 +00:00
|
|
|
// brotli compression
|
2018-10-27 08:08:12 +00:00
|
|
|
hexo.config.neat_brotli = Object.assign({
|
2018-10-25 09:35:59 +00:00
|
|
|
enable: true,
|
2019-04-23 05:40:43 +00:00
|
|
|
logger: false,
|
2019-07-10 02:20:23 +00:00
|
|
|
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
|
2019-08-06 01:53:58 +00:00
|
|
|
globOptions: { basename: true }
|
2018-10-25 09:35:59 +00:00
|
|
|
}, hexo.config.neat_brotli)
|
2018-09-30 07:30:32 +00:00
|
|
|
|
2018-10-26 04:57:23 +00:00
|
|
|
const filter = require('./lib/filter')
|
2018-10-25 09:35:59 +00:00
|
|
|
hexo.extend.filter.register('after_render:html', filter.logicHtml)
|
|
|
|
hexo.extend.filter.register('after_render:css', filter.logicCss)
|
|
|
|
hexo.extend.filter.register('after_render:js', filter.logicJs)
|
2019-04-23 07:59:35 +00:00
|
|
|
hexo.extend.filter.register('after_generate', filter.logicSvg)
|
2018-10-25 09:35:59 +00:00
|
|
|
hexo.extend.filter.register('after_generate', filter.logicGzip)
|
|
|
|
hexo.extend.filter.register('after_generate', filter.logicBrotli)
|
2018-09-29 05:38:45 +00:00
|
|
|
}
|