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 () {
|
export default async function () {
|
||||||
const s = Date.now()
|
const s = Date.now()
|
||||||
let errors = []
|
let errors = []
|
||||||
|
if (this.options.generate.minify === true) delete this.options.generate.minify
|
||||||
/*
|
/*
|
||||||
** Set variables
|
** Set variables
|
||||||
*/
|
*/
|
||||||
@ -105,18 +106,20 @@ export default async function () {
|
|||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
errors.push({ type: 'unhandled', route, error: err })
|
errors.push({ type: 'unhandled', route, error: err })
|
||||||
}
|
}
|
||||||
try {
|
if (self.options.generate.minify !== false) {
|
||||||
var minifiedHtml = minify(html, self.options.generate.minify)
|
try {
|
||||||
} catch (err) /* istanbul ignore next */ {
|
var minifiedHtml = minify(html, self.options.generate.minify)
|
||||||
let minifyErr = new Error(`HTML minification failed. Make sure the route generates valid HTML. Failed HTML:\n ${html}`)
|
} catch (err) /* istanbul ignore next */ {
|
||||||
errors.push({ type: 'unhandled', route, error: minifyErr })
|
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
|
var path = join(route, sep, 'index.html') // /about -> /about/index.html
|
||||||
debug('Generate file: ' + path)
|
debug('Generate file: ' + path)
|
||||||
path = join(distPath, path)
|
path = join(distPath, path)
|
||||||
// Make sure the sub folders are created
|
// Make sure the sub folders are created
|
||||||
await mkdirp(dirname(path))
|
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
|
// Add .nojekyll file to let Github Pages add the _nuxt/ folder
|
||||||
|
Loading…
Reference in New Issue
Block a user