1. After npm run build is successfully packaged, index.html and static folders will be generated in the dist directory, and all files in dist will be copied to the directory you need.
2. Configure nginx, the following is a simple configuration:
server {
listen 8011 default;
server_name localhost;
location / {
#Configure the root directory of the website, that is, the path where index.html and static are located
root /Users/wqz/git/outdoor-ui/dist;
try_files $uri $uri/ /index.html last;
index index.html;
add_header Access-Control-Allow-Origin *;
}
#Configure cross-domain forwarding, if your project needs to request data from other servers, you can configure it, otherwise you can
location /auth/ {
proxy_pass http://127.0.0.1:9002;
}
location /admin/ {
proxy_pass http://127.0.0.1:9002;
}
access_log logs/outdoor-ui.access.log;
}
After the configuration is complete, reload the nginx configuration and use the command sudo nginx -s reload . If it is not started, just start it directly.
3. Access localhost:8011.