fix Conflicting

This commit is contained in:
ausir 2017-05-21 22:47:03 +08:00
commit 3f56457f79

View File

@ -46,7 +46,6 @@ export default async function () {
** Set variables ** Set variables
*/ */
this.options.generate = _.defaultsDeep(this.options.generate, defaults) this.options.generate = _.defaultsDeep(this.options.generate, defaults)
var self = this
var srcStaticPath = resolve(this.srcDir, 'static') var srcStaticPath = resolve(this.srcDir, 'static')
var srcBuiltPath = resolve(this.dir, '.nuxt', 'dist') var srcBuiltPath = resolve(this.dir, '.nuxt', 'dist')
var distPath = resolve(this.dir, this.options.generate.dir) var distPath = resolve(this.dir, this.options.generate.dir)
@ -54,7 +53,7 @@ export default async function () {
/* /*
** Launch build process ** Launch build process
*/ */
await self.build() await this.build()
/* /*
** Clean destination folder ** Clean destination folder
*/ */
@ -96,30 +95,32 @@ export default async function () {
while (routes.length) { while (routes.length) {
let n = 0 let n = 0
await Promise.all(routes.splice(0, 500).map(async (route) => { await Promise.all(routes.splice(0, 500).map(async (route) => {
await waitFor(n++ * self.options.generate.interval) await waitFor(n++ * this.options.generate.interval)
let html
try { try {
var { html, error } = await self.renderRoute(route, { _generate: true }) const res = await this.renderRoute(route, { _generate: true })
if (error) { html = res.html
errors.push({ type: 'handled', route, error }) if (res.error) {
errors.push({ type: 'handled', route, error: res.error })
} }
} catch (err) { } catch (err) {
/* istanbul ignore next */ /* istanbul ignore next */
errors.push({ type: 'unhandled', route, error: err }) errors.push({ type: 'unhandled', route, error: err })
} }
if (self.options.generate.minify !== false) { if (this.options.generate.minify !== false) {
try { try {
var minifiedHtml = minify(html, self.options.generate.minify) html = minify(html, this.options.generate.minify)
} catch (err) /* istanbul ignore next */ { } catch (err) /* istanbul ignore next */ {
let minifyErr = new Error(`HTML minification failed. Make sure the route generates valid HTML. Failed HTML:\n ${html}`) 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 }) errors.push({ type: 'unhandled', route, error: minifyErr })
} }
} }
var path = join(route, sep, 'index.html') // /about -> /about/index.html let 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 || html, 'utf8') await writeFile(path, html, 'utf8')
})) }))
} }
// Add .nojekyll file to let Github Pages add the _nuxt/ folder // Add .nojekyll file to let Github Pages add the _nuxt/ folder