forked from chenzhutian/hexo-all-minifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
63 lines (52 loc) · 1.69 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
/* global hexo */
var isEnabled = process.env.NODE_ENV !== 'development' &&
(hexo.config.hasOwnProperty('all_minifier') === false || hexo.config.all_minifier === true);
if (isEnabled) {
// HTML minifier
hexo.config.html_minifier = Object.assign({
enable: true,
exclude: [],
ignoreCustomComments: [/^\s*more/],
removeComments: true,
removeCommentsFromCDATA: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeEmptyAttributes: true,
minifyJS: true,
minifyCSS: true
}, hexo.config.html_minifier);
// Css minifier
hexo.config.css_minifier = Object.assign({
enable: true,
exclude: ['*.min.css']
}, hexo.config.css_minifier);
// Js minifier
hexo.config.js_minifier = Object.assign({
enable: true,
mangle: true,
output: {},
compress: {},
exclude: ['*.min.js']
}, hexo.config.js_minifier);
// Image minifier
hexo.config.image_minifier = Object.assign({
enable: true,
interlaced: false,
multipass: false,
optimizationLevel: 3,
pngquant: false,
progressive: false
}, hexo.config.image_minifier);
// Js concator
hexo.config.js_concator = Object.assign({
enable: false,
bundle_path: 'js/bundle.js',
use_versioned_bundle: false,
front: false,
}, hexo.config.js_concator);
hexo.extend.filter.register('after_render:html', require('./lib/optimizeHTML'));
hexo.extend.filter.register('after_render:css', require('./lib/optimizeCSS'));
hexo.extend.filter.register('after_render:js', require('./lib/optimizeJS'));
hexo.extend.filter.register('after_generate', require('./lib/optimizeImage'));
hexo.extend.filter.register('after_generate', require('./lib/concatJS'));
}