Skip to content

serve -s build not sending gzip-ed files to the browser. #5620

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
MichaelDimmitt opened this issue Oct 29, 2018 · 6 comments
Closed

serve -s build not sending gzip-ed files to the browser. #5620

MichaelDimmitt opened this issue Oct 29, 2018 · 6 comments

Comments

@MichaelDimmitt
Copy link

MichaelDimmitt commented Oct 29, 2018

Is this a bug report?

Maybe, issue is with the dependency; more for tracking visibility of serve -s build

I installed create-react-app on a mac on October 28th.
My current version of serve:

serve --version
10.0.2 

Maybe a solution for this problem is temporarily locking in a version of serve that did support gzip.
looks like this issue and this pr from the serve repo.
(If I figure out the version that has gzip support I will post the update.)

Expected Behavior

gzip-difference

Actual Behavior

The serve dependency is not sending gzip-ed files to the browser.
cra-example

Related to 1908. Running command, npm run build; serve -s build

Documented further on their issues page, vercel/serve#460

I have a current workaround in that I am manually gzip-ing the files and using express-static-gzip

Here are the files from my workaround so that I could do prod build without ejecting:

  1. "alternative" script in package.json
  2. "server.js" file for express
  3. Also notice I had to add express and express-static to the package.json

Eager to hear other alternatives for solving the problem.
Happy to provide additional information or help in anyway.

@miraage
Copy link

miraage commented Oct 30, 2018

What is your intention of serve usage? It is a tool just to run a static webserver. It is not a production tool by any mean.

@MichaelDimmitt
Copy link
Author

MichaelDimmitt commented Oct 30, 2018

@miraage, in create react app after running npm run build

Output: 
Creating an optimized production build...
file sizes after gzip ...
...
You may serve it with a static server:
  npm install -g serve
  serve -s build

Serve is the recommended static server to use for production build for create-react-app.
My intention is to run an app in production on a heroku server without ejecting create-react-app.

(Disclaimer: I know some information but am not an expert at production configs)
From what I can tell, create-react-app's production build config's are the same configs that I would use if creating a production build.
I currently need to gzip the files manually and send them with express-static-gzip.

But that is a workaround, I would rather use the recommended serve package if an older version achieved the gzip-ing files to the server.

@miraage
Copy link

miraage commented Oct 30, 2018

You **may** serve it with a static server means "you can try to see how your apps works after being built for production usage". Just think about what app would serve faster: the one which was written in C++ or NodeJS?

If you want to use heroku you don't need to use the serve package.
Link with instructions for heroku deployment.

@gaearon
Copy link
Contributor

gaearon commented Oct 30, 2018

Yeah. We raised this with them before since it used to work.
vercel/serve#460 (comment)

@ketysek
Copy link

ketysek commented Nov 11, 2018

I have an app in docker a this was the easiest way to serve it. Should I change the server to something else or will it be resolved?

@MichaelDimmitt
Copy link
Author

MichaelDimmitt commented Nov 12, 2018

serve updated their code to support gzip 🙂,
Confirmed working, after running

npm uninstall -g serve; npm install -g serve;
serve -s build;

serve is now gzipping the files. current latest version: serve@10.1.1

@lock lock bot locked and limited conversation to collaborators Jan 9, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants