Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run create-react-app build version

I have created a test React application and I started it with the create-react-app. I am starting it with with yarn start, but that starts the debug version of the application. I did npm run build and it created the build folder, however when I do yarn start from the /build folder, it still starts the debug version of the application. I need this for testing performance with the optimized version. How can I solve this?

like image 881
gfels Avatar asked Apr 11 '18 21:04

gfels


People also ask

How do I find the build the React app version for a project?

The other method is also straightforward, you can check the React app version by heading over to node_modules/react/cjs/react. development. js. You can see the react project version in the commented section as showing given below.

How does create React app run?

Create React App (CRA) is a tool to create single-page React applications that is officially supported by the React team. The script generates the required files and folders to start the React application and run it on the browser.


2 Answers

You can actually use static server to run build version of your app. It's doable with serve. You can test it with:

npm run build

npx serve -s build

like image 82
piasek Avatar answered Nov 15 '22 11:11

piasek


Navigate inside the directory of your app first.

According to the official create-react-app website. When you run npm run build or yarn build you create a build directory with a production build of your app.

After running the command above the next thing you can do to check the build version of your app is to install serve to serve your static site on the port 5000 by default.

npm install -g serve
serve -s build

This will copy the link to your clipboard that you can paste in your browser and see the build version of your app.

like image 41
proprgrmmr Avatar answered Nov 15 '22 10:11

proprgrmmr