mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-09 03:03:18 +00:00
add generate.minify can set boolean
false will skip html-minifier true will use default minify setting
This commit is contained in:
parent
dd32b5441f
commit
4390b44814
@ -41,6 +41,7 @@ const defaults = {
|
||||
export default async function () {
|
||||
const s = Date.now()
|
||||
let errors = []
|
||||
if (this.options.generate.minify === true) delete this.options.generate.minify
|
||||
/*
|
||||
** Set variables
|
||||
*/
|
||||
@ -105,18 +106,20 @@ export default async function () {
|
||||
/* istanbul ignore next */
|
||||
errors.push({ type: 'unhandled', route, error: err })
|
||||
}
|
||||
try {
|
||||
var minifiedHtml = minify(html, self.options.generate.minify)
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
let minifyErr = new Error(`HTML minification failed. Make sure the route generates valid HTML. Failed HTML:\n ${html}`)
|
||||
errors.push({ type: 'unhandled', route, error: minifyErr })
|
||||
if (self.options.generate.minify !== false) {
|
||||
try {
|
||||
var minifiedHtml = minify(html, self.options.generate.minify)
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
let minifyErr = new Error(`HTML minification failed. Make sure the route generates valid HTML. Failed HTML:\n ${html}`)
|
||||
errors.push({ type: 'unhandled', route, error: minifyErr })
|
||||
}
|
||||
}
|
||||
var path = join(route, sep, 'index.html') // /about -> /about/index.html
|
||||
debug('Generate file: ' + path)
|
||||
path = join(distPath, path)
|
||||
// Make sure the sub folders are created
|
||||
await mkdirp(dirname(path))
|
||||
await writeFile(path, minifiedHtml, 'utf8')
|
||||
await writeFile(path, minifiedHtml || html, 'utf8')
|
||||
}))
|
||||
}
|
||||
// Add .nojekyll file to let Github Pages add the _nuxt/ folder
|
||||
|
Loading…
Reference in New Issue
Block a user