Skip to content

Add BuildProgressPlugin #1011

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
33 changes: 33 additions & 0 deletions packages/react-dev-utils/BuildProgressPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

const path = require('path');

const ProgressPlugin = require('webpack').ProgressPlugin;
const ProgressBar = require('progress');
const chalk = require('chalk');

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

module.exports = BuildProgressPlugin;
5 changes: 5 additions & 0 deletions packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"node": ">=4"
},
"files": [
"BuildProgressPlugin.js",
"clearConsole.js",
"checkRequiredFiles.js",
"formatWebpackMessages.js",
Expand All @@ -28,7 +29,11 @@
"escape-string-regexp": "1.0.5",
"html-entities": "1.2.0",
"opn": "4.0.2",
"progress": "1.1.8",
"sockjs-client": "1.0.1",
"strip-ansi": "3.0.1"
},
"devDependencies": {
"webpack": "^1.14.0"
}
}
5 changes: 4 additions & 1 deletion packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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');

// @remove-on-eject-begin
// `path` is not used after eject - see https://github.com/facebookincubator/create-react-app/issues/1174
Expand Down Expand Up @@ -268,7 +269,9 @@ module.exports = {
// having to parse `index.html`.
new ManifestPlugin({
fileName: 'asset-manifest.json'
})
}),
// Displays a progress bar during the build
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