Unverified Commit b8da5849 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub
Browse files

Optimize webpack rebuild speed (#5065)

Derived from https://github.com/facebook/create-react-app/issues/4492#issuecomment-421959548
parent b181f926
Showing with 9 additions and 3 deletions
+9 -3
...@@ -28,7 +28,7 @@ function printFileSizesAfterBuild( ...@@ -28,7 +28,7 @@ function printFileSizesAfterBuild(
var assets = (webpackStats.stats || [webpackStats]) var assets = (webpackStats.stats || [webpackStats])
.map(stats => .map(stats =>
stats stats
.toJson() .toJson({ all: false, assets: true })
.assets.filter(asset => /\.(js|css)$/.test(asset.name)) .assets.filter(asset => /\.(js|css)$/.test(asset.name))
.map(asset => { .map(asset => {
var fileContents = fs.readFileSync(path.join(root, asset.name)); var fileContents = fs.readFileSync(path.join(root, asset.name));
......
...@@ -150,7 +150,11 @@ function createCompiler(webpack, config, appName, urls, useYarn) { ...@@ -150,7 +150,11 @@ function createCompiler(webpack, config, appName, urls, useYarn) {
// We have switched off the default Webpack output in WebpackDevServer // We have switched off the default Webpack output in WebpackDevServer
// options so we are going to "massage" the warnings and errors and present // options so we are going to "massage" the warnings and errors and present
// them in a readable focused way. // them in a readable focused way.
const messages = formatWebpackMessages(stats.toJson({}, true)); // We only construct the warnings and errors for speed:
// https://github.com/facebook/create-react-app/issues/4492#issuecomment-421959548
const messages = formatWebpackMessages(
stats.toJson({ all: false, warnings: true, errors: true })
);
const isSuccessful = !messages.errors.length && !messages.warnings.length; const isSuccessful = !messages.errors.length && !messages.warnings.length;
if (isSuccessful) { if (isSuccessful) {
console.log(chalk.green('Compiled successfully!')); console.log(chalk.green('Compiled successfully!'));
......
...@@ -142,7 +142,9 @@ function build(previousFileSizes) { ...@@ -142,7 +142,9 @@ function build(previousFileSizes) {
if (err) { if (err) {
return reject(err); return reject(err);
} }
const messages = formatWebpackMessages(stats.toJson({}, true)); const messages = formatWebpackMessages(
stats.toJson({ all: false, warnings: true, errors: true })
);
if (messages.errors.length) { if (messages.errors.length) {
// Only keep the first error. Others are often indicative // Only keep the first error. Others are often indicative
// of the same problem, but confuse the reader with noise. // of the same problem, but confuse the reader with noise.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment