Merge pull request #155 from curbengh/dependabot/github_actions/codecov/codecov-action-4
[hexo-yam.git] / index.js
blob318533a6ac1590ae7b9ba095645a5e2f9c8bfc8f
1 /* global hexo */
2 'use strict'
4 hexo.config.minify = Object.assign({
5   enable: true
6 }, hexo.config.minify)
8 hexo.config.minify.html = Object.assign({
9   enable: true,
10   priority: 10,
11   verbose: false,
12   exclude: [],
13   collapseBooleanAttributes: true,
14   collapseWhitespace: true,
15   // Ignore '<!-- more -->' https://hexo.io/docs/tag-plugins#Post-Excerpt
16   ignoreCustomComments: [/^\s*more/],
17   removeComments: true,
18   removeEmptyAttributes: true,
19   removeScriptTypeAttributes: true,
20   removeStyleLinkTypeAttributes: true,
21   minifyJS: true,
22   minifyCSS: true,
23   globOptions: { basename: true }
24 }, hexo.config.minify.html)
26 hexo.config.minify.css = Object.assign({
27   enable: true,
28   priority: 10,
29   verbose: false,
30   exclude: ['*.min.css'],
31   level: 2,
32   globOptions: { basename: true }
33 }, hexo.config.minify.css)
35 hexo.config.minify.js = Object.assign({
36   enable: true,
37   priority: 10,
38   verbose: false,
39   exclude: ['*.min.js'],
40   compress: {},
41   mangle: true,
42   output: {},
43   globOptions: { basename: true }
44 }, hexo.config.minify.js)
46 hexo.config.minify.svg = Object.assign({
47   enable: true,
48   priority: 10,
49   verbose: false,
50   include: ['*.svg', '!*.min.svg'],
51   plugins: {},
52   globOptions: { basename: true }
53 }, hexo.config.minify.svg)
55 hexo.config.minify.gzip = Object.assign({
56   enable: true,
57   priority: 10,
58   verbose: false,
59   include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
60   globOptions: { basename: true }
61 }, hexo.config.minify.gzip)
63 hexo.config.minify.brotli = Object.assign({
64   enable: true,
65   priority: 10,
66   verbose: false,
67   include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
68   globOptions: { basename: true }
69 }, hexo.config.minify.brotli)
71 hexo.config.minify.xml = Object.assign({
72   enable: false,
73   priority: 10,
74   verbose: false,
75   include: ['*.xml', '!*.min.xml'],
76   removeComments: true,
77   globOptions: { basename: true }
78 }, hexo.config.minify.xml)
80 hexo.config.minify.json = Object.assign({
81   enable: false,
82   priority: 10,
83   verbose: false,
84   include: ['*.json', '!*.min.json'],
85   globOptions: { basename: true }
86 }, hexo.config.minify.json)
88 if (hexo.config.minify.enable === true) {
89   const filter = require('./lib/filter')
90   hexo.extend.filter.register('after_render:html', filter.minifyHtml, hexo.config.minify.html.priority)
91   hexo.extend.filter.register('after_render:css', filter.minifyCss, hexo.config.minify.css.priority)
92   hexo.extend.filter.register('after_render:js', filter.minifyJs, hexo.config.minify.js.priority)
93   hexo.extend.filter.register('after_generate', filter.minifySvg, hexo.config.minify.svg.priority)
94   hexo.extend.filter.register('after_generate', filter.gzipFn, hexo.config.minify.gzip.priority)
95   hexo.extend.filter.register('after_generate', filter.brotliFn, hexo.config.minify.brotli.priority)
96   hexo.extend.filter.register('after_generate', filter.minifyXml, hexo.config.minify.xml.priority)
97   hexo.extend.filter.register('after_generate', filter.minifyJson, hexo.config.minify.json.priority)