From 53f9d62fce8f830aa97ca39e611d5a5363e63a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 24 Mar 2017 01:25:41 +0100 Subject: [PATCH] Add generate.minify option --- lib/generate.js | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/generate.js b/lib/generate.js index ff41d7bfe1..eef9681037 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -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)