Generate Production Code
If your terminal is still running Vite for development, press CTRL + c to terminate Vite.
In the terminal, run the following command to have Vite build a production ready app that can hosted on a server.
# npm run build
Notice that we now have a subdirectory named dist. Take a few minutes to inspect the contents of dist.
Test the Production Code
In a terminal install the serve npm module using the following command. This module will allow us to power up a node web server.
On Windows
$ npm install -g serve
On MacOS
$ sudo npm install -g serve
Now start serve using the command below and click on the Local link displayed in the terminal.
$ serve -s dist
If successful, your web app should be running on a local server and you should see a localhost URL in the console. Hover over the URL and click on the Link to run your application in the browser.