vue.jsdev-to-production

How to run production build in VueJs?


I have worked to a VueJs project locally. Now I have to upload it on a VM of my university and it will become public. I think I should not upload the entire directory but only the 'dist' directory that I created with the command:

npm run build

First question: Is it correct?

Second question: How do I run the server now? For local's test I used to run it with the command:

npm run serve

but I think now I should use some other commands.

Thank you for help.


Solution

  • Answer for questions:

    1. Yes. It is correct.

    2. Usually, you will need to serve the dist folder in a web server. Like nginx or apache.

    It will work serving your index.html, inside /dist folder generated in the build step of your vuejs application.

    Obs.: you should not serve your application in production with npm run serve as it is a development server monothreaded.