Skip to content

Conversation

Nitive
Copy link
Contributor

@Nitive Nitive commented May 1, 2016

Usage:

app.use(webpackDevMiddleware(compiler, {
  reporter: ({ state, stats, options }) => {
    console.log('log what you want')
  }
}))

Example reporter:

const oraReporter = () => {
  const spinner = ora()
  spinner.start()
  return ({ state, stats }) => {
    if (state) {
      const durations = stats.endTime - stats.startTime
      const formatedDurations = durations >= 1000 ? `${durations / 1000} s` : `${durations} ms`
      const message = `Completed in ${formatedDurations.magenta}`

      if (stats.hasErrors() || stats.hasWarnings()) {
        spinner.clear()
        const { errors, warnings } = stats.compilation
        errors.concat(warnings).forEach(warning => {
          console.log(warning.message)
        })
      }

      spinner.text = message
    } else {
      spinner.text = 'Building...'
    }
  }
}

@SpaceK33z
Copy link
Member

Thanks, I really like it!

@SpaceK33z
Copy link
Member

Released in 1.7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants