Skip to content

Commit bfa757a

Browse files
committed
fix(breaking): color consistency in build console output. fixes #2
1 parent 198bb13 commit bfa757a

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ node_modules
66
.nyc_output
77
coverage.lcov
88

9+
dist
910
test/fixtures/**/dist
1011

1112
.eslintcache

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ module.exports = {
8686

8787
✨ Magic. The `webpack-nano/argv` export provides quick and easy access to parsed command-line arguments, allowing the user to define the CLI experience as they want to.
8888

89+
## Build Stats
90+
91+
This project attempts not to make assumptions about how a build should behave, and that includes webpack [`stats`](https://webpack.js.org/configuration/stats/). By default, `webpack-nano` will apply two `stats` options: `colors` (based on [`supports-color`](https://github.com/chalk/supports-color) and `exclude: ['node_modules']`). These can be quickly overridden by including these key/values in your stats configuration.
92+
8993
## Meta
9094

9195
[CONTRIBUTING](./.github/CONTRIBUTING.md)

bin/wp.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,16 @@ webpack v${webpack.version}
124124
return;
125125
}
126126

127-
const defaultStatsOptions = { colors: chalk.supportsColor, exclude: ['node_modules'] };
127+
const statsDefaults = { colors: chalk.supportsColor.hasBasic, exclude: ['node_modules'] };
128128
const { options = {} } =
129129
[]
130130
.concat(compiler.compilers || compiler)
131131
.reduce((a, c) => c.options.stats && c.options.stats) || {};
132-
133-
const result = stats.toString(options.stats == null ? defaultStatsOptions : options.stats);
132+
const statsOptions =
133+
!options.stats || typeof options.stats === 'object'
134+
? Object.assign({}, statsDefaults, options.stats)
135+
: options.stats;
136+
const result = stats.toString(statsOptions);
134137

135138
log.info(result);
136139
};

0 commit comments

Comments
 (0)