前端部署
1. 新建生产配置文件
根目录新建.env.production
,加入如下内容
ENV = 'production'
# 接口地址 改成自己域名
VUE_APP_BASE_API = 'http://admin.xxx.com/admin'
VUE_APP_WS_API = 'ws://admin.xxx.com/admin'
2. 编译打包
#根目录执行
npm run build
3. 上传服务器
把打包后的dist目录代码上传到服务器
4. 配置nginx如下:
server
{
listen 80;
server_name admin.xxx.com;
# 加入以下配置
location / {
try_files $uri $uri/ @router;
index index.html;
}
# 加入以下配置
location @router {
rewrite ^.*$ /index.html last;
}
}