Skip to content
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

FileSizeReporter reports with wrong (hardcoded) path. #2357

Closed
fezhengjin opened this issue May 25, 2017 · 5 comments
Closed

FileSizeReporter reports with wrong (hardcoded) path. #2357

fezhengjin opened this issue May 25, 2017 · 5 comments

Comments

@fezhengjin
Copy link
Contributor

Can you reproduce the problem with latest npm?

yes

Description

When i changed the value of appBuild property to dist in "react-scripts/config/paths.js" and run npm run build, the printFileSizesAfterBuild function logged wrong paths.

Expected behavior

Log in the console should be like:

File sizes after gzip:

  16.13 KB  dist/static/js/main.3a5b25c4.js
  5.72 KB   dist/static/css/main.dc21d15c.css

Actual behavior

But it still reported with "build" in paths:

File sizes after gzip:

  16.13 KB  build/static/js/main.3a5b25c4.js
  5.72 KB   build/static/css/main.dc21d15c.css

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected):
  2. node -v: v7.4.0
  3. npm -v: 4.0.5

Then, specify:

  1. Operating system: macOS Sierra 10.12.4
  2. Browser and version:

Hardcode

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-dev-utils/FileSizeReporter.js#L33

@gaearon
Copy link
Contributor

gaearon commented May 25, 2017

Good catch. Want to send a PR that passes appBuild folder into that function?

@fezhengjin
Copy link
Contributor Author

@gaearon It's my pleasure.

@noseglid
Copy link

noseglid commented May 30, 2017

This never made it into the documentation, which still incorrectly states

printFileSizesAfterBuild(webpackStats: WebpackStats, previousFileSizes: OpaqueFileSizes)

when in fact it should be

printFileSizesAfterBuild(webpackStats: WebpackStats, previousFileSizes: OpaqueFileSizes, buildFolder: string)

or this happens

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

/Users/noseglid/devel/content-admin/scripts/build.js:10
  throw err;
  ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.basename (path.js:1355:5)
    at webpackStats.toJson.assets.filter.map.asset (/Users/noseglid/devel/content-admin/node_modules/react-dev-utils/FileSizeReporter.js:34:32)
    at Array.map (native)
    at printFileSizesAfterBuild (/Users/noseglid/devel/content-admin/node_modules/react-dev-utils/FileSizeReporter.js:27:6)
    at measureFileSizesBeforeBuild.then.then (/Users/noseglid/devel/content-admin/scripts/build.js:68:7)

@gaearon
Copy link
Contributor

gaearon commented May 30, 2017

Good point. Want to send a PR?

@gaearon
Copy link
Contributor

gaearon commented May 30, 2017

Reopened for docs.

@gaearon gaearon reopened this May 30, 2017
@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants