Search code examples
webpackwebpack-dev-middleware

How to get --color output when using webpack-dev-middleware?


I have an express API I'm using in my app so I am using webpack-dev-middleware and webpack-hot-middleware.

I'm trying to figure out how to get the webpack --color option when I use webpack through the API.

This is what I have right now:

const webpack = require('webpack')
const webpackConfig = require('../../webpack.config')
const compiler = webpack(webpackConfig)

const webpackDevMiddleware = require('webpack-dev-middleware')(compiler, {
  noInfo: true
})
const webpackHotMiddleware = require('webpack-hot-middleware')(compiler)

app.use(webpackDevMiddleware)
app.use(webpackHotMiddleware)

I am currently using [email protected].


Solution

  • Here, add

    stats: {
      colors: true
    }
    

    to your options, like:

    const webpackDevMiddleware = require('webpack-dev-middleware')(compiler, {
      noInfo: true,
      stats: {
        colors: true
      }
    })
    

    Check out the usage section.

    Tested with webpack 2.2.1 and webpack-dev-middleware 1.10.1.