I would like to run a vite react app locally in production mode? What is the best way of doing it?
Run react app locally in production mode using vite?
Asked Answered
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
Please note that viet preview isn't meant for production mode! –
Halter
@Halter could you please describe your statement bit more? –
Polly
See Vite documentation: "It is important to note that vite preview is intended for previewing the build locally and not meant as a production server." –
Halter
© 2022 - 2024 — McMap. All rights reserved.
npx serve
command from the dist/build directory. – Benthamism