Skip to content

Commit 0002a40

Browse files
authored
Merge pull request #261 from dangcuuson/webpack-stats
Allow webpack stats option to overwrite default behaviour
2 parents 5c9f14d + a4ed8a1 commit 0002a40

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ module.exports = {
144144
};
145145
```
146146

147+
### Stats
148+
149+
By default, the plugin will print a quite verbose bundle information to your console. However, if
150+
you are not satisfy with the current output info, you can overwrite it in your `webpack.config.js`
151+
152+
```js
153+
// webpack.config.js
154+
155+
module.export = {
156+
// ...
157+
stats: 'minimal'
158+
// ...
159+
}
160+
```
161+
162+
All the stats config can be found in [webpack's documentation](https://webpack.js.org/configuration/stats/)
163+
164+
147165
### Node modules / externals
148166

149167
By default, the plugin will try to bundle all dependencies. However, you don't

lib/compile.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ module.exports = {
1919
}
2020

2121
const compileOutputPaths = [];
22+
const consoleStats = this.webpackConfig.stats || {
23+
colors: true,
24+
hash: false,
25+
version: false,
26+
chunks: false,
27+
children: false
28+
};
2229

2330
_.forEach(stats.stats, compileStats => {
24-
this.serverless.cli.consoleLog(compileStats.toString({
25-
colors: true,
26-
hash: false,
27-
version: false,
28-
chunks: false,
29-
children: false
30-
}));
31+
this.serverless.cli.consoleLog(compileStats.toString(consoleStats));
3132

3233
if (compileStats.compilation.errors.length) {
3334
throw new Error('Webpack compilation error, see above');

lib/wpwatch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
}
2323

2424
if (stats) {
25-
console.log(stats.toString()); // eslint-disable-line no-console
25+
this.serverless.cli.consoleLog(stats.toString(this.webpackConfig.stats));
2626
}
2727
});
2828

0 commit comments

Comments
 (0)