Add generate.minify option

This commit is contained in:
Sébastien Chopin 2017-03-24 01:25:41 +01:00
parent 8f277af03b
commit 53f9d62fce

View File

@ -15,7 +15,27 @@ const mkdirp = pify(fs.mkdirp)
const defaults = {
dir: 'dist',
routes: []
routes: [],
minify: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
minifyCSS: true,
minifyJS: true,
processConditionalComments: true,
removeAttributeQuotes: false,
removeComments: false,
removeEmptyAttributes: true,
removeOptionalTags: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: false,
removeStyleLinkTypeAttributes: false,
removeTagWhitespace: false,
sortAttributes: true,
sortClassName: true,
trimCustomFragments: true,
useShortDoctype: true
}
}
export default function () {
@ -75,26 +95,7 @@ export default function () {
yield routes.splice(0, 500).map((route) => {
return co(function * () {
var { html } = yield self.renderRoute(route, { _generate: true })
html = minify(html, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
minifyCSS: true,
minifyJS: true,
processConditionalComments: true,
removeAttributeQuotes: false,
removeComments: false,
removeEmptyAttributes: true,
removeOptionalTags: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
removeTagWhitespace: true,
sortAttributes: true,
sortClassName: true,
trimCustomFragments: true,
useShortDoctype: true
})
html = minify(html, self.options.generate.minify)
var path = join(route, sep, 'index.html') // /about -> /about/index.html
debug('Generate file: ' + path)
path = join(distPath, path)