參考資源:Vue 打包后靜態資源加前綴,頁面路由加前綴,修改靜態資源訪問路徑
1.具體需求:
一個端口下,需要配置多個靜態站點,用不同的路徑區分。比如:localhost:9001/adminA,就訪問A系統;localhost:9001/adminB,就訪問B系統.
2.項目背景:
1)Nginx代理
2)靜態資源是用vue打包的。
3.具體操作:
1)vue設置靜態資源(css、js)的路徑前綴。這個需要根據不同的vue-cli版本,進行不同的設置。原因是默認打包后,css和js的url路徑,是不包含我們用來區分不同靜態站點的路徑前綴的,需要配置一下。
vue-cli版本:3.0
靜態資源前綴:
vue.config.js 中: module.exports ={ publicPath:”/前綴" , …...}
2)nginx配置:
server { listen 9002; server_name localhost; location / { root "H:\code\ceshi\serverweb"; index index.html; } location /test2 { alias "H:\code\ceshi\submitweb"; index index.html; } }