Skip to content

Add BuildProgressPlugin #950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions packages/react-dev-utils/BuildProgressPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

'use strict';

const path = require('path');

let ProgressPlugin;
if (__dirname.indexOf(path.join('packages', 'react-dev-utils')) !== -1) {
ProgressPlugin = require('../react-scripts/node_modules/webpack').ProgressPlugin;
} else {
ProgressPlugin = require('webpack').ProgressPlugin;
}
const ProgressBar = require('progress');
const chalk = require('chalk');

function BuildProgressPlugin() {
const bar = new ProgressBar(` [:bar] ${chalk.bold(':percent')} ${chalk.yellow(':etas')} (${chalk.dim(':msg')})`, {
total: 100,
complete: '=',
incomplete: ' ',
width: 25
})
return new ProgressPlugin(function(percent, msg) {
if (percent === 1) msg = 'completed';
bar.update(percent, { msg });
if (percent === 1) bar.terminate();
});
}

module.exports = BuildProgressPlugin;
1 change: 1 addition & 0 deletions packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"escape-string-regexp": "1.0.5",
"html-entities": "1.2.0",
"opn": "4.0.2",
"progress": "1.1.8",
"sockjs-client": "1.0.3",
"strip-ansi": "3.0.1"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
var url = require('url');
var paths = require('./paths');
var getClientEnvironment = require('./env');
var BuildProgressPlugin = require('react-dev-utils/BuildProgressPlugin');

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