azureviteazure-deployment

Vite React Deployment to Azure as a Web App


I am trying to deploy a new web app to Azure. It is a React app using Vite framework and I use React Router DOM. I can create the resources at Azure and deploy from my Visual Studio by right clicking on the app service and then "Deploy to Web App..."

I also have the following at package.json:

  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },

The deploy seems to be working fine and I can see the files under the app resource but the website still shows the default welcome page.


Solution

  • I had to change the startup command to the following to solve the issue. I hope it will help someone in the future...

    pm2 serve /home/site/wwwroot/dist --no-daemon --spa