Skip to content

Commit af5957c

Browse files
committed
Add BuildProgressPlugin
1 parent 7cd03f9 commit af5957c

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
5+
const ProgressPlugin = require('webpack').ProgressPlugin;
6+
const ProgressBar = require('progress');
7+
const chalk = require('chalk');
8+
9+
function BuildProgressPlugin() {
10+
const bar = new ProgressBar(` [:bar] ${ chalk.bold(':percent') } ${ chalk.yellow(':etas') } (${ chalk.dim(':msg') })`, {
11+
total: 100,
12+
complete: '=',
13+
incomplete: ' ',
14+
width: 25
15+
});
16+
return new ProgressPlugin(function (percent, msg) {
17+
if (percent === 1) msg = 'completed';
18+
bar.update(percent, { msg });
19+
if (percent === 1) bar.terminate();
20+
});
21+
}
22+
23+
module.exports = BuildProgressPlugin;

packages/react-dev-utils/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"node": ">=4"
1212
},
1313
"files": [
14+
"BuildProgressPlugin.js",
1415
"clearConsole.js",
1516
"checkRequiredFiles.js",
1617
"formatWebpackMessages.js",
@@ -28,7 +29,11 @@
2829
"escape-string-regexp": "1.0.5",
2930
"html-entities": "1.2.0",
3031
"opn": "4.0.2",
32+
"progress": "1.1.8",
3133
"sockjs-client": "1.0.1",
3234
"strip-ansi": "3.0.1"
35+
},
36+
"devDependencies": {
37+
"webpack": "^1.14.0"
3338
}
3439
}

packages/react-scripts/config/webpack.config.prod.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
1818
var url = require('url');
1919
var paths = require('./paths');
2020
var getClientEnvironment = require('./env');
21+
var BuildProgressPlugin = require('react-dev-utils/BuildProgressPlugin');
2122

2223
// @remove-on-eject-begin
2324
// `path` is not used after eject - see https://github.com/facebookincubator/create-react-app/issues/1174
@@ -268,7 +269,9 @@ module.exports = {
268269
// having to parse `index.html`.
269270
new ManifestPlugin({
270271
fileName: 'asset-manifest.json'
271-
})
272+
}),
273+
// Displays a progress bar during the build
274+
new BuildProgressPlugin()
272275
],
273276
// Some libraries import Node modules but don't use them in the browser.
274277
// Tell Webpack to provide empty mocks for them so importing them works.

0 commit comments

Comments
 (0)