reactjsviteproduction-environment

Run react app locally in production mode using vite?


I would like to run a vite react app locally in production mode? What is the best way of doing it?


Solution

  • Go to package.json file of you vite react app.

    modify your script like that :

    {
      "scripts": {
        "build": "vite build",
        "serve": "vite preview"
      }
    }
    

    then run :

    npm run build
    
    npm run serve