Skip to content

Commit 944fa46

Browse files
committed
Add BuildProgressPlugin
1 parent 613902c commit 944fa46

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
'use strict';
11+
12+
const ProgressPlugin = require('webpack').ProgressPlugin;
13+
const ProgressBar = require('progress');
14+
const chalk = require('chalk');
15+
16+
function BuildProgressPlugin() {
17+
const bar = new ProgressBar(` [:bar] ${chalk.bold(':percent')} ${chalk.yellow(':etas')} (${chalk.dim(':msg')})`, {
18+
total: 100,
19+
complete: '=',
20+
incomplete: ' ',
21+
width: 25
22+
})
23+
return new ProgressPlugin(function(percent, msg) {
24+
if (percent === 1) msg = 'completed';
25+
bar.update(percent, { msg: msg });
26+
if (percent === 1) bar.terminate();
27+
});
28+
}
29+
30+
module.exports = BuildProgressPlugin;

packages/react-dev-utils/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
"escape-string-regexp": "1.0.5",
2828
"html-entities": "1.2.0",
2929
"opn": "4.0.2",
30+
"progress": "1.1.8",
3031
"sockjs-client": "1.0.3",
31-
"strip-ansi": "3.0.1"
32-
},
33-
"peerDependencies": {
32+
"strip-ansi": "3.0.1",
3433
"webpack": "^1.13.2"
3534
}
3635
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
1919
var url = require('url');
2020
var paths = require('./paths');
2121
var getClientEnvironment = require('./env');
22+
var BuildProgressPlugin = require('react-dev-utils/BuildProgressPlugin');
2223

2324
function ensureSlash(path, needsSlash) {
2425
var hasSlash = path.endsWith('/');
@@ -257,7 +258,8 @@ module.exports = {
257258
// having to parse `index.html`.
258259
new ManifestPlugin({
259260
fileName: 'asset-manifest.json'
260-
})
261+
}),
262+
new BuildProgressPlugin()
261263
],
262264
// Some libraries import Node modules but don't use them in the browser.
263265
// Tell Webpack to provide empty mocks for them so importing them works.

0 commit comments

Comments
 (0)