mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 22:46:30 +08:00
Fix file size report after build (#5335)
Fixes #5333 printFileSizesAfterBuild calls canReadAsset with an object containing the file name while measureFileSizesBeforeBuild calls it with just the name. When canReadAsset only receives the name it returns false since accessing the `name` property results in undefined. This commit fixes that by having canReadAssset instead expect only the file name and making printFileSizesAfterBuild just like measureFileSizesBeforeBuild only provide the name as argument.
This commit is contained in:
committed by
Joe Haddad
parent
b201aee073
commit
9fd98447d8
8
packages/react-dev-utils/FileSizeReporter.js
vendored
8
packages/react-dev-utils/FileSizeReporter.js
vendored
@@ -17,9 +17,9 @@ var gzipSize = require('gzip-size').sync;
|
||||
|
||||
function canReadAsset(asset) {
|
||||
return (
|
||||
/\.(js|css)$/.test(asset.name) &&
|
||||
!/service-worker\.js/.test(asset.name) &&
|
||||
!/precache-manifest\.[0-9a-f]+\.js/.test(asset.name)
|
||||
/\.(js|css)$/.test(asset) &&
|
||||
!/service-worker\.js/.test(asset) &&
|
||||
!/precache-manifest\.[0-9a-f]+\.js/.test(asset)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ function printFileSizesAfterBuild(
|
||||
.map(stats =>
|
||||
stats
|
||||
.toJson({ all: false, assets: true })
|
||||
.assets.filter(canReadAsset)
|
||||
.assets.filter(asset => canReadAsset(asset.name))
|
||||
.map(asset => {
|
||||
var fileContents = fs.readFileSync(path.join(root, asset.name));
|
||||
var size = gzipSize(fileContents);
|
||||
|
||||
Reference in New Issue
Block a user