mirror of https://github.com/curbengh/hexo-yam
feat: enable plugin by default and update options naming
This commit is contained in:
parent
2930f1da1d
commit
7e85bd6338
36
index.js
36
index.js
|
@ -1,9 +1,11 @@
|
||||||
/* global hexo */
|
/* global hexo */
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
if (hexo.config.neat_enable === true) {
|
hexo.config.minify = Object.assign({
|
||||||
// HTML minifier
|
enable: true
|
||||||
hexo.config.neat_html = Object.assign({
|
}, hexo.config.minify)
|
||||||
|
|
||||||
|
hexo.config.minify.html = Object.assign({
|
||||||
enable: true,
|
enable: true,
|
||||||
logger: false,
|
logger: false,
|
||||||
exclude: [],
|
exclude: [],
|
||||||
|
@ -18,19 +20,17 @@ if (hexo.config.neat_enable === true) {
|
||||||
minifyJS: true,
|
minifyJS: true,
|
||||||
minifyCSS: true,
|
minifyCSS: true,
|
||||||
globOptions: { basename: true }
|
globOptions: { basename: true }
|
||||||
}, hexo.config.neat_html)
|
}, hexo.config.minify.html)
|
||||||
|
|
||||||
// CSS minifier
|
hexo.config.minify.css = Object.assign({
|
||||||
hexo.config.neat_css = Object.assign({
|
|
||||||
enable: true,
|
enable: true,
|
||||||
logger: false,
|
logger: false,
|
||||||
exclude: ['*.min.css'],
|
exclude: ['*.min.css'],
|
||||||
level: 2,
|
level: 2,
|
||||||
globOptions: { basename: true }
|
globOptions: { basename: true }
|
||||||
}, hexo.config.neat_css)
|
}, hexo.config.minify.css)
|
||||||
|
|
||||||
// Javascript minifier
|
hexo.config.minify.js = Object.assign({
|
||||||
hexo.config.neat_js = Object.assign({
|
|
||||||
enable: true,
|
enable: true,
|
||||||
logger: false,
|
logger: false,
|
||||||
exclude: ['*.min.js'],
|
exclude: ['*.min.js'],
|
||||||
|
@ -38,33 +38,31 @@ if (hexo.config.neat_enable === true) {
|
||||||
mangle: true,
|
mangle: true,
|
||||||
output: {},
|
output: {},
|
||||||
globOptions: { basename: true }
|
globOptions: { basename: true }
|
||||||
}, hexo.config.neat_js)
|
}, hexo.config.minify.js)
|
||||||
|
|
||||||
// SVG minifier
|
hexo.config.minify.svg = Object.assign({
|
||||||
hexo.config.neat_svg = Object.assign({
|
|
||||||
enable: true,
|
enable: true,
|
||||||
logger: false,
|
logger: false,
|
||||||
include: ['*.svg', '!*.min.svg'],
|
include: ['*.svg', '!*.min.svg'],
|
||||||
plugins: [],
|
plugins: [],
|
||||||
globOptions: { basename: true }
|
globOptions: { basename: true }
|
||||||
}, hexo.config.neat_svg)
|
}, hexo.config.minify.svg)
|
||||||
|
|
||||||
// gzip compression
|
hexo.config.minify.gzip = Object.assign({
|
||||||
hexo.config.neat_gzip = Object.assign({
|
|
||||||
enable: true,
|
enable: true,
|
||||||
logger: false,
|
logger: false,
|
||||||
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
|
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
|
||||||
globOptions: { basename: true }
|
globOptions: { basename: true }
|
||||||
}, hexo.config.neat_gzip)
|
}, hexo.config.minify.gzip)
|
||||||
|
|
||||||
// brotli compression
|
hexo.config.minify.brotli = Object.assign({
|
||||||
hexo.config.neat_brotli = Object.assign({
|
|
||||||
enable: true,
|
enable: true,
|
||||||
logger: false,
|
logger: false,
|
||||||
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
|
include: ['*.html', '*.css', '*.js', '*.txt', '*.ttf', '*.atom', '*.stl', '*.xml', '*.svg', '*.eot', '*.json'],
|
||||||
globOptions: { basename: true }
|
globOptions: { basename: true }
|
||||||
}, hexo.config.neat_brotli)
|
}, hexo.config.minify.brotli)
|
||||||
|
|
||||||
|
if (hexo.config.minify.enable === true) {
|
||||||
const filter = require('./lib/filter')
|
const filter = require('./lib/filter')
|
||||||
hexo.extend.filter.register('after_render:html', filter.logicHtml)
|
hexo.extend.filter.register('after_render:html', filter.logicHtml)
|
||||||
hexo.extend.filter.register('after_render:css', filter.logicCss)
|
hexo.extend.filter.register('after_render:css', filter.logicCss)
|
||||||
|
|
|
@ -18,7 +18,7 @@ function isMatch (path, patterns, options) {
|
||||||
|
|
||||||
function logicHtml (str, data) {
|
function logicHtml (str, data) {
|
||||||
const hexo = this
|
const hexo = this
|
||||||
const options = hexo.config.neat_html
|
const options = hexo.config.minify.html
|
||||||
// Return if disabled.
|
// Return if disabled.
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ function logicHtml (str, data) {
|
||||||
|
|
||||||
function logicCss (str, data) {
|
function logicCss (str, data) {
|
||||||
const hexo = this
|
const hexo = this
|
||||||
const options = hexo.config.neat_css
|
const options = hexo.config.minify.css
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
const path = data.path
|
const path = data.path
|
||||||
|
@ -72,7 +72,7 @@ function logicCss (str, data) {
|
||||||
|
|
||||||
function logicJs (str, data) {
|
function logicJs (str, data) {
|
||||||
const hexo = this
|
const hexo = this
|
||||||
const options = hexo.config.neat_js
|
const options = hexo.config.minify.js
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
const path = data.path
|
const path = data.path
|
||||||
|
@ -103,7 +103,7 @@ function logicJs (str, data) {
|
||||||
|
|
||||||
function logicSvg () {
|
function logicSvg () {
|
||||||
const hexo = this
|
const hexo = this
|
||||||
const options = hexo.config.neat_svg
|
const options = hexo.config.minify.svg
|
||||||
// Return if disabled.
|
// Return if disabled.
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ function logicSvg () {
|
||||||
|
|
||||||
function logicGzip () {
|
function logicGzip () {
|
||||||
const hexo = this
|
const hexo = this
|
||||||
const options = hexo.config.neat_gzip
|
const options = hexo.config.minify.gzip
|
||||||
// Return if disabled.
|
// Return if disabled.
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ function logicGzip () {
|
||||||
|
|
||||||
function logicBrotli () {
|
function logicBrotli () {
|
||||||
const hexo = this
|
const hexo = this
|
||||||
const options = hexo.config.neat_brotli
|
const options = hexo.config.minify.brotli
|
||||||
// Return if disabled.
|
// Return if disabled.
|
||||||
if (options.enable === false) return
|
if (options.enable === false) return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue