Skip to content

Commit

Permalink
tempoary impl ignore dev ssr log
Browse files Browse the repository at this point in the history
  • Loading branch information
potato4d committed May 14, 2019
1 parent 62a593d commit 6ea3080
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions packages/config/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { NuxtConfigurationServer } from './server'
import { NuxtConfigurationServerMiddleware } from './server-middleware'
import { NuxtConfigurationVueConfiguration } from './vue-configuration'
import { NuxtConfigurationWatchers } from './watchers'
import { NuxtConfigurationLogs } from './logs'

type ExtendableConfiguration = { [key: string]: any }

Expand Down Expand Up @@ -49,6 +50,7 @@ export default interface NuxtConfiguration extends ExtendableConfiguration {
'vue.config'?: NuxtConfigurationVueConfiguration
watch?: string[]
watchers?: NuxtConfigurationWatchers
logs: NuxtConfigurationLogs
}

export {
Expand Down
3 changes: 3 additions & 0 deletions packages/config/types/logs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface NuxtConfigurationLogs {
ignoreDevSSR: boolean
}
24 changes: 15 additions & 9 deletions packages/vue-renderer/src/renderers/ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,25 @@ export default class SSRRenderer extends BaseRenderer {
}

async devRenderToString(renderContext) {
const logs = []
const devReporter = {
log(logObj) {
if (logObj.args[0] instanceof Error) {
logObj.args[0] = logObj.args[0].stack
if (this.options.logs && !this.options.logs.ignoreDevSSR) {
const logs = []
const devReporter = {
log(logObj) {
if (logObj.args[0] instanceof Error) {
logObj.args[0] = logObj.args[0].stack
}
logs.push(logObj)
}
logs.push(logObj)
}
consola.addReporter(devReporter)
}
consola.addReporter(devReporter)

const APP = await this.vueRenderer.renderToString(renderContext)
consola.removeReporter(devReporter)
renderContext.nuxt.logs = logs

if (this.options.logs && !this.options.logs.ignoreDevSSR) {
consola.removeReporter(devReporter)
renderContext.nuxt.logs = logs
}

return APP
}
Expand Down

0 comments on commit 6ea3080

Please sign in to comment.