Skip to content

Commit aea53fe

Browse files
authored
Merge pull request #71 from weaverryan/better-success-output
Adding a new plugin to give a little bit of a summary after a successful build
2 parents b0cc956 + 8f21ea2 commit aea53fe

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

lib/config-generator.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const webpack = require('webpack');
1313
const ExtractTextPlugin = require('extract-text-webpack-plugin');
1414
const ManifestPlugin = require('./webpack/webpack-manifest-plugin');
1515
const DeleteUnusedEntriesJSPlugin = require('./webpack/delete-unused-entries-js-plugin');
16+
const AssetsOutputDisplayPlugin = require('./friendly-errors/asset-output-display-plugin');
1617
const loaderFeatures = require('./loader-features');
1718
const CleanWebpackPlugin = require('clean-webpack-plugin');
1819
const WebpackChunkHash = require('webpack-chunk-hash');
@@ -56,8 +57,8 @@ class ConfigGenerator {
5657
}
5758

5859
config.performance = {
59-
// silence performance hints when we're in dev
60-
hints: this.webpackConfig.isProduction() ? 'warning' : false
60+
// silence performance hints
61+
hints: false
6162
};
6263

6364
config.stats = this.buildStatsConfig();
@@ -394,7 +395,7 @@ class ConfigGenerator {
394395
]);
395396
}
396397

397-
plugins.push(new FriendlyErrorsWebpackPlugin({
398+
const friendlyErrorsPlugin = new FriendlyErrorsWebpackPlugin({
398399
clearConsole: false,
399400
additionalTransformers: [
400401
missingLoaderTransformer,
@@ -403,8 +404,15 @@ class ConfigGenerator {
403404
additionalFormatters: [
404405
missingLoaderFormatter,
405406
missingPostCssConfigFormatter
406-
]
407-
}));
407+
],
408+
compilationSuccessInfo: {
409+
messages: []
410+
}
411+
});
412+
plugins.push(friendlyErrorsPlugin);
413+
414+
const outputPath = this.webpackConfig.outputPath.replace(this.webpackConfig.getContext() + '/', '');
415+
plugins.push(new AssetsOutputDisplayPlugin(outputPath, friendlyErrorsPlugin));
408416

409417
return plugins;
410418
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file is part of the Symfony package.
3+
*
4+
* (c) Fabien Potencier <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
'use strict';
11+
12+
const chalk = require('chalk');
13+
14+
function AssetOutputDisplayPlugin(outputPath, friendlyErrorsPlugin) {
15+
this.outputPath = outputPath;
16+
this.friendlyErrorsPlugin = friendlyErrorsPlugin;
17+
}
18+
19+
AssetOutputDisplayPlugin.prototype.apply = function(compiler) {
20+
compiler.plugin('emit', (compilation, callback) => {
21+
// completely reset messages key to avoid adding more and more messages
22+
// when using watch
23+
this.friendlyErrorsPlugin.compilationSuccessInfo.messages = [
24+
`${chalk.yellow(Object.keys(compilation.assets).length)} files written to ${chalk.yellow(this.outputPath)}`
25+
];
26+
27+
callback();
28+
});
29+
};
30+
31+
module.exports = AssetOutputDisplayPlugin;

0 commit comments

Comments
 (0)