问题描述:
同一个端口部署pc和app端项目,Nginx配置,前端打包配置
解决方案:
- 配置pc端vue项目打包配置
- 配置uniapp项目打包配置,manifest.json文件添加配置
"h5": {
"router": {
"mode": "hash",
"base": "./"//改为 /app/
},
// pubilcPath的路径要和H5配置中的运行基础路径一致
"publicPath": "./", //改为 /app/
"devServer": {
"disableHostCheck": true,
//禁止访问本地host文件
"port": 8088,
"https": false
},
"sdkConfigs": {
"maps": {
"qqmap": {
"key": ""
}
}
},
"title": "XXXXXXX",
"optimization": {
"treeShaking": {
"enable": true
}
}
}
- Nginx config配置
server {
listen 3114 default_server;
listen [::]:3114 default_server;
server_name _;
root /mnt/menghai_ds;
location /pc/ {
alias /mnt/menghai_ds/pc/;
index index.html index.htm;
}
location /app/{
alias /mnt/menghai_ds/app/;
index index.html index.htm;
}
}