add html minifier for generate

This commit is contained in:
Alexandre Chopin 2016-12-12 23:09:08 +01:00
parent 7f3a39fea1
commit 4ebe6f7ac8
2 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,7 @@ const pathToRegexp = require('path-to-regexp')
const _ = require('lodash')
const { resolve, join, dirname, sep } = require('path')
const { promisifyRouteParams } = require('./utils')
const { minify } = require('html-minifier')
const copy = pify(fs.copy)
const remove = pify(fs.remove)
const writeFile = pify(fs.writeFile)
@ -87,7 +88,10 @@ module.exports = function () {
while (routes.length) {
yield routes.splice(0, 500).map((route) => {
return co(function * () {
const { html } = yield self.renderRoute(route)
var { html } = yield self.renderRoute(route)
html = minify(html, {
collapseWhitespace: true
})
var path = join(route, sep, 'index.html') // /about -> /about/index.html
debug('Generate file: ' + path)
path = join(distPath, path)

View File

@ -63,6 +63,7 @@
"fs-extra": "^1.0.0",
"glob": "^7.1.1",
"hash-sum": "^1.0.2",
"html-minifier": "^3.2.3",
"lodash": "^4.17.2",
"lru-cache": "^4.0.2",
"memory-fs": "^0.4.1",