-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Creating Gzip files while build #3169
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
Comments
I'd also vote for this feature because GZip files have already been creating for the size difference. |
I thought about the api:
|
I don't feel like this is in the scope of CRA - isn't the web server's job to gzip assets before sending them to the browser ? |
@bogdan-calapod take a glance at https://github.com/facebookincubator/create-react-app/blob/v1.0.13/packages/react-dev-utils/FileSizeReporter.js#L128 This function is invoked during the build. It's using zlib.gzipSync method: https://nodejs.org/dist/latest/docs/api/zlib.html#zlib_zlib_gzipsync_buffer_options It's already happening. All they need is to dump this files to the disk. |
And if it is the web server that gzip the assets, it is done dynamically, so you have to regzip your assets every time (Nginx has a cache but that's not the point) |
Gzipping files is usually done by the CI / manually. By default, static web servers do not handle statically gzipped files (need extra configuration). I'm guessing that people needing to statically gzip the It's a cool feature to have, but it doesn't feel in CRA's scope. |
I'm pretty sure this is most often handled by the web server, e.g. express has a gzip option, and I'm sure nginx has an option for this too. I'm not sure I see the value in us providing these by default. Let me know if I'm wrong. Also, I feel like this is easily accomplished with a |
Since you think it is out of scope of CRA, can you suggest an npm package that runs as "post-build" or a "deploy" script and gzip all my "build/" files? I'm on Windows, Linux, Mac machines (everytime changes). |
Hey @johnunclesam ! If you're searching for a cli gzip utility in Node, any wrapper cli using |
in case anyone is looking how to do it in nginx for configurations can go to nginx docs can read this link further
|
With the current config of CRA when you build the project, the files aren't gzipped so if you want to serve gzipped files, you have to either gzipped dynamically or to eject.
What could be awesome is when a build is run, two folders are created in the build folder: one regular and one with the gzipped files. Or having the possibility to set a env var GZIP and build only one folder, gzipped or not
The text was updated successfully, but these errors were encountered: