Deployment
Read the documentation carefully, you will learn about how you can deploy the production builds on the server.
Last updated
Read the documentation carefully, you will learn about how you can deploy the production builds on the server.
Last updated
To create a production build you need to run the command npm run build
. It will create the dist
folder, that contains the production build files. Now you just need to upload the dist
files on to the server.
To run the production build locally, the easiest way to handle this would be to install and let it handle the rest:
You don’t necessarily need a static server in order to run a project in production. It works just as fine as integrated into an existing dynamic one.
Here’s a programmatic example using and :
Apache HTTP server:
Upload the dist
files in the public folder.
By default, vue-cli 3 produces a build, assuming your app is hosted at the server root. To override this, follow the instructions given below:-
Create a .htaccess
file in the sub directory.
Open vue.config.js
file and change the baseUrl
from '/'
to '/sub-folder/'
Change all static assets path with your directory path e.g. "/static/img/user-1.jpg"
with "/sub-folder/static/img/user-1.jpg"
Add base in the router config file, go to the src->router
and open index.js
file.
Run npm run build
command.
Upload the dist
folder files on the sub-folder directory.
For more information, please check the link below:
That's it, Now your production build will work on the relative path.
If you’re using , you need to create a .htaccess
file in the public
folder that looks like this: