Skip to content

Commit

Permalink
don't mutate stats configuration (#1174)
Browse files Browse the repository at this point in the history
The webpack configuration `stats` property has the same format as the
`devServer.stats` property, so the same object is frequently reused to
define the same stats output.

Since webpack v3.8.0, the `stats` property is validated more strictly by
webpack.  webpack-dev-server is mutating this `stats` object by adding a
`colors` property, which is an object and doesn't match the webpack
configuration schema, causing a fatal error.

The easy fix is to *not* mutate the `stats` object, so webpack isn't
breaking with a fatal error.  But we may also consider setting a valid
`colors` property.
  • Loading branch information
BenoitZugmeyer authored and shellscape committed Dec 22, 2017
1 parent ef18fc8 commit 32c3ceb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/webpack-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ function processOptions(webpackOptions) {
};
}

if (typeof options.stats === 'object' && typeof options.stats.colors === 'undefined') { options.stats.colors = argv.color; }
if (typeof options.stats === 'object' && typeof options.stats.colors === 'undefined') {
options.stats = Object.assign({}, options.stats, { colors: argv.color });
}

if (argv.lazy) { options.lazy = true; }

Expand Down

0 comments on commit 32c3ceb

Please sign in to comment.