-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
75 lines (68 loc) · 2.24 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* global hexo */
'use strict'
if (hexo.config.neat_enable === true) {
// HTML minifier
hexo.config.neat_html = Object.assign({
enable: true,
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: { matchBase: true }
}, hexo.config.neat_html)
// CSS minifier
hexo.config.neat_css = Object.assign({
enable: true,
logger: false,
exclude: ['*.min.css'],
level: 2,
globOptions: { matchBase: true }
}, hexo.config.neat_css)
// Javascript minifier
hexo.config.neat_js = Object.assign({
enable: true,
logger: false,
exclude: ['*.min.js'],
compress: {},
mangle: true,
output: {},
globOptions: { matchBase: true }
}, hexo.config.neat_js)
// SVG minifier
hexo.config.neat_svg = Object.assign({
enable: true,
logger: false,
include: ['*.svg', '!*.min.svg'],
plugins: [],
globOptions: { matchBase: true }
}, hexo.config.neat_svg)
// gzip compression
hexo.config.neat_gzip = Object.assign({
enable: true,
logger: false,
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
globOptions: { matchBase: true }
}, hexo.config.neat_gzip)
// brotli compression
hexo.config.neat_brotli = Object.assign({
enable: true,
logger: false,
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
globOptions: { matchBase: true }
}, hexo.config.neat_brotli)
const filter = require('./lib/filter')
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)
hexo.extend.filter.register('after_generate', filter.logicSvg)
hexo.extend.filter.register('after_generate', filter.logicGzip)
hexo.extend.filter.register('after_generate', filter.logicBrotli)
}