Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporter option #91

Merged
merged 2 commits into from
Aug 25, 2016
Merged

Reporter option #91

merged 2 commits into from
Aug 25, 2016

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