hexo-yam/index.js

81 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-05-26 11:09:41 +00:00
/* global hexo */
2019-05-27 01:14:04 +00:00
'use strict'
hexo.config.minify = Object.assign({
enable: true
}, hexo.config.minify)
2016-05-26 11:09:41 +00:00
hexo.config.minify.html = Object.assign({
enable: true,
2019-10-09 22:33:34 +00:00
priority: 10,
logger: false,
exclude: [],
collapseBooleanAttributes: true,
collapseWhitespace: true,
// Ignore '<!-- more -->' https://hexo.io/docs/tag-plugins#Post-Excerpt
ignoreCustomComments: [/^\s*more/],
removeComments: true,
removeEmptyAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
minifyJS: true,
minifyCSS: true,
globOptions: { basename: true }
}, hexo.config.minify.html)
2016-05-26 11:09:41 +00:00
hexo.config.minify.css = Object.assign({
enable: true,
2019-10-09 22:33:34 +00:00
priority: 10,
2019-09-24 22:56:44 +00:00
// TODO: rename to verbose
logger: false,
exclude: ['*.min.css'],
level: 2,
globOptions: { basename: true }
}, hexo.config.minify.css)
2016-05-26 11:09:41 +00:00
hexo.config.minify.js = Object.assign({
enable: true,
2019-10-09 22:33:34 +00:00
priority: 10,
logger: false,
exclude: ['*.min.js'],
compress: {},
mangle: true,
output: {},
globOptions: { basename: true }
}, hexo.config.minify.js)
2019-04-23 07:59:35 +00:00
hexo.config.minify.svg = Object.assign({
enable: true,
2019-10-09 22:33:34 +00:00
priority: 10,
logger: false,
include: ['*.svg', '!*.min.svg'],
plugins: [],
globOptions: { basename: true }
}, hexo.config.minify.svg)
2016-05-26 11:09:41 +00:00
hexo.config.minify.gzip = Object.assign({
enable: true,
2019-10-09 22:33:34 +00:00
priority: 10,
logger: false,
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
globOptions: { basename: true }
}, hexo.config.minify.gzip)
2018-09-30 07:30:32 +00:00
hexo.config.minify.brotli = Object.assign({
enable: true,
2019-10-09 22:33:34 +00:00
priority: 10,
logger: false,
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
globOptions: { basename: true }
}, hexo.config.minify.brotli)
if (hexo.config.minify.enable === true) {
const filter = require('./lib/filter')
2019-10-09 22:33:34 +00:00
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)
}