skip to Main Content

Hello I have a simple question, I think, but I didn’t find an answer.

I know that React uses JSX and so, because of the browser knows only Vanilla JS, the code to be run should be compiled. When I run yarn build, the code will be minified ad compiled and the resulting files are in a build folder. Then, If I want to deploy the site for example using Netlify, I need to setup the build command. Basically Netlify build the apps, save the built files somewhere and serve these files.

What I am asking now is how the start command works. In that case, how does the browser can read the React files? Everytime I run yarn start the start script run also a build in watch mode or something like this?

(i’m supposing I’m using create-react-app)

2

Answers


  1. start command simply compiles all your code to view and edit locally. We can say that we have created a local build. But that is just for our understanding.

    Whereas build command creates a folder to be served online on a server to be viewed (only) on internet.

    Both commands have a huge difference.This question can help you more.
    Happy Coding:-)

    Login or Signup to reply.
  2. As Per your question, It depends on your script, by default NO.

    These are all custom script, you can find the definition in package.json file. Normally start is for starting the development build, build is for making the production build.

    For Example - 
    
    **"scripts": {
    "start": "react-scripts start",
    "lint": "eslint ./src",
    "lint:fix": "eslint ./src --fix",
    "test": "react-scripts test",
    "test:coverage": "react-scripts test --coverage --watchAll=false",
    "build": "rollup -c",**
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search