Skip to content

Commit b8da584

Browse files
authored
Optimize webpack rebuild speed (#5065)
Derived from #4492 (comment)
1 parent b181f92 commit b8da584

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

packages/react-dev-utils/FileSizeReporter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function printFileSizesAfterBuild(
2828
var assets = (webpackStats.stats || [webpackStats])
2929
.map(stats =>
3030
stats
31-
.toJson()
31+
.toJson({ all: false, assets: true })
3232
.assets.filter(asset => /\.(js|css)$/.test(asset.name))
3333
.map(asset => {
3434
var fileContents = fs.readFileSync(path.join(root, asset.name));

packages/react-dev-utils/WebpackDevServerUtils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ function createCompiler(webpack, config, appName, urls, useYarn) {
150150
// We have switched off the default Webpack output in WebpackDevServer
151151
// options so we are going to "massage" the warnings and errors and present
152152
// them in a readable focused way.
153-
const messages = formatWebpackMessages(stats.toJson({}, true));
153+
// We only construct the warnings and errors for speed:
154+
// https://github.com/facebook/create-react-app/issues/4492#issuecomment-421959548
155+
const messages = formatWebpackMessages(
156+
stats.toJson({ all: false, warnings: true, errors: true })
157+
);
154158
const isSuccessful = !messages.errors.length && !messages.warnings.length;
155159
if (isSuccessful) {
156160
console.log(chalk.green('Compiled successfully!'));

packages/react-scripts/scripts/build.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ function build(previousFileSizes) {
142142
if (err) {
143143
return reject(err);
144144
}
145-
const messages = formatWebpackMessages(stats.toJson({}, true));
145+
const messages = formatWebpackMessages(
146+
stats.toJson({ all: false, warnings: true, errors: true })
147+
);
146148
if (messages.errors.length) {
147149
// Only keep the first error. Others are often indicative
148150
// of the same problem, but confuse the reader with noise.

0 commit comments

Comments
 (0)