Adam Silva
Adam Silva

Reputation: 1047

Vuejs Testing app in web server

Locally on my computer, I'm able to run npm run serve to test out my app. However, what if I wanted to do the same on my server? Where should I point my domain to?

Or whenever I want to test on my server, do I have to run npm run build and point my domain to /dist?

I'm asking because if I'm on a different computer, I don't want to have to clone the project every time and install npm and stuff to make it work. This way I would only need to have access to a terminal to test my app out wihout doing npm run build every time I make a change.

Upvotes: 0

Views: 509

Answers (2)

You want run Vue-Cli on Server, you do ways after or you see:Deploy a VueJS App with DigitalOcean,How To Set Up a Node.js Application for Production on CentOS 7

step:1: install nodejs on Sever
step:2: install vue-cli (version 2 or 3)
step:3:cd to project, you run command: npm run build
step:4: you need install nginx on server
step:5: sudo nano /etc/nginx/nginx.conf, you edit the following:
server{
	listen 80;
	server_name domail.com 
	root /var/www/project-vue-cli/dist;
	index index.html index.htm index.php
	location / {
		try_files $uri $uri/ =404;
	}

}

step:6: you restart nginx: sudo systemctl restart nginx
step:7: you can open domain

Upvotes: 0

Ohgodwhy
Ohgodwhy

Reputation: 50767

You must be talking about vue-cli. Indeed, when you npm run build the output of your application is in /dist. You would serve the index.html from here.

It would be best to put a web server in front of it, declare the location to serve the assets from (the same as the root path, I'd imagine) and then you're off to the races.

However, you can also just use ngrok and setup some port forwarding on your local router. This will make it available publicly as well if you just want to preview things.

Upvotes: 1

Related Questions