创建环境变量, 创建.env.production
#这个前缀可以让nginx作反代
VUE_APP_BASE_API = '/api'
改一下输出地址,vue.confifig.jsoutputDir: 'dist/best-practice',
构建: npm run build
部署
部署只需要将最终生成的静态文件,通常是 dist 文件夹下的静态文件发布到 cdn 或者静态服务器即可。 这里我们采用nginx作为web服务器,具体配置nginx-1.14.0/conf/nginx.conf:
#项目根, 大家改成自己的目录
root C: \\Users\\ yt037\\ Desktop\\ kaikeba\\ projects\\ vue - study\\ dist;#
项目dist目录# history fallback
location / best - practice {
try_files $uri / best - practice / index.html;
}#
反向代理, 实现接口转发
location ^ ~/api/ {
#把 / api去除
rewrite ^ /api/(.*) $ / $1
break;
#代理到3000服务上
proxy_pass http: //localhost:3000;
}
common_rules2.conf;
location /wcg/api/ {
#测试
proxy_pass http://27.155.67.227:8000/wcg/api/;
#正式
#proxy_pass https://wcgcenter.wostore.cn/wcg/api/;
break;
}
location /wcg/mobile/api/ {
#测试
proxy_pass http://27.115.67.257:8000/wcg/mobile/api/;
#正式
#proxy_pass https://wcgcenter.wostore.cn/wcg/mobile/api/;
break;
}
location /wcg/logs {
proxy_pass https://wcgter.wostre.cn/wcg/logs;
break;
}
nginx.conf
include common_rules2.conf;
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。