Merge branch 'master' into fixes

This commit is contained in:
Sébastien Chopin 2017-05-05 16:50:24 +02:00 committed by GitHub
commit 072216c045
4 changed files with 17 additions and 17 deletions

View File

@ -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
}

View File

@ -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
})

View File

@ -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)

View File

@ -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)
)
}
}),