mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
Merge branch 'master' into fixes
This commit is contained in:
commit
072216c045
18
lib/build.js
18
lib/build.js
@ -425,11 +425,7 @@ function webpackWatchAndUpdate () {
|
||||
if (err) throw err
|
||||
const bundleExists = serverFS.existsSync(bundlePath)
|
||||
const manifestExists = clientFS.existsSync(manifestPath)
|
||||
if (!bundleExists) {
|
||||
debug('Waiting for server bundle...')
|
||||
} else if (!manifestExists) {
|
||||
debug('Waiting for client manifest...')
|
||||
} else {
|
||||
if (bundleExists && manifestExists) {
|
||||
const bundle = serverFS.readFileSync(bundlePath, 'utf8')
|
||||
const manifest = clientFS.readFileSync(manifestPath, 'utf8')
|
||||
createRenderer.call(this, JSON.parse(bundle), JSON.parse(manifest))
|
||||
@ -463,11 +459,13 @@ function webpackRunServer () {
|
||||
const bundlePath = join(serverConfig.output.path, 'server-bundle.json')
|
||||
const manifestPath = join(serverConfig.output.path, 'client-manifest.json')
|
||||
readFile(bundlePath, 'utf8')
|
||||
.then(bundle => readFile(manifestPath, 'utf8')
|
||||
.then(bundle => {
|
||||
readFile(manifestPath, 'utf8')
|
||||
.then(manifest => {
|
||||
createRenderer.call(this, JSON.parse(bundle), JSON.parse(manifest))
|
||||
resolve()
|
||||
}))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -485,8 +483,10 @@ function createRenderer (bundle, manifest) {
|
||||
this.renderer = createBundleRenderer(bundle, Object.assign({
|
||||
cache: cacheConfig,
|
||||
clientManifest: manifest,
|
||||
runInNewContext: false
|
||||
}, this.options.ssr))
|
||||
runInNewContext: false,
|
||||
inject: false,
|
||||
baseDir: this.options.dir
|
||||
}, this.options.build.ssr))
|
||||
this.renderToString = pify(this.renderer.renderToString)
|
||||
this.renderToStream = this.renderer.renderToStream
|
||||
}
|
||||
|
@ -101,17 +101,17 @@ export default function () {
|
||||
try {
|
||||
var { html, error } = yield self.renderRoute(route, { _generate: true })
|
||||
if (error) {
|
||||
errors.push({type: 'handled', route, error})
|
||||
errors.push({ type: 'handled', route, error })
|
||||
}
|
||||
} catch (err) {
|
||||
errors.push({type: 'unhandled', route, error: err})
|
||||
errors.push({ type: 'unhandled', route, error: err })
|
||||
return
|
||||
}
|
||||
try {
|
||||
var minifiedHtml = minify(html, self.options.generate.minify)
|
||||
} catch (err) {
|
||||
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 })
|
||||
return
|
||||
}
|
||||
var path = join(route, sep, 'index.html') // /about -> /about/index.html
|
||||
@ -136,14 +136,14 @@ export default function () {
|
||||
debug(`HTML Files generated in ${duration}s`)
|
||||
|
||||
if (errors.length) {
|
||||
/* eslint-disable no-console */
|
||||
console.error('==== Error report ==== \n' + errors.map(({type, route, error}) => {
|
||||
const report = errors.map(({ type, route, error }) => {
|
||||
if (type === 'unhandled') {
|
||||
return `Route: '${route}'\n${error.stack}`
|
||||
} else {
|
||||
return `Route: '${route}' thrown an error: \n` + JSON.stringify(error)
|
||||
}
|
||||
}).join('\n\n'))
|
||||
})
|
||||
console.error('==== Error report ==== \n' + report).join('\n\n') // eslint-disable-line no-console
|
||||
}
|
||||
return this
|
||||
})
|
||||
|
@ -93,7 +93,7 @@ export function renderRoute (url, context = {}) {
|
||||
// Add url and isSever to the context
|
||||
context.url = url
|
||||
context.isServer = true
|
||||
// Call renderToSting from the bundleRenderer and generate the HTML (will update the context as well)
|
||||
// Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)
|
||||
const self = this
|
||||
return co(function * () {
|
||||
let APP = yield self.renderToString(context)
|
||||
|
@ -62,7 +62,7 @@ export default function () {
|
||||
// If it's inside node_modules
|
||||
/node_modules/.test(module.context) &&
|
||||
// Do not externalize if the request is a CSS file
|
||||
!/\.css$/.test(module.request)
|
||||
!/\.(css|less|scss|sass|styl|stylus)$/.test(module.request)
|
||||
)
|
||||
}
|
||||
}),
|
||||
|
Loading…
Reference in New Issue
Block a user