-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
53 lines (48 loc) · 1.3 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
/* global hexo */
'use strict';
const { deepMerge } = require('hexo-util');
hexo.config.filter_optimize = deepMerge({
enable : true,
versioning: false,
css : {
minify : true,
excludes: [],
delivery: [],
inlines : []
},
js: {
minify : true,
excludes : [],
remove_comments: false
},
html: {
minify : true,
excludes: []
},
image: {
minify : true,
interlaced : false,
multipass : false,
optimizationLevel: 2,
pngquant : false,
progressive : false
}
}, hexo.config.filter_optimize);
const config = hexo.config.filter_optimize;
if (process.env.NODE_ENV !== 'development' && config.enable) {
const { filter, css, js } = require('./lib/index');
const priority = parseInt(config.priority, 10) || 10;
// Enable one of the optimizations.
if (config.css.delivery.length || config.css.inlines.length || config.html.minify || config.versioning) {
hexo.extend.filter.register('after_generate', filter, priority);
}
if (config.css.minify) {
hexo.extend.filter.register('after_render:css', css);
}
if (config.js.minify) {
hexo.extend.filter.register('after_render:js', js);
}
if (config.image.minify) {
//hexo.extend.filter.register('after_generate', image);
}
}