welcome
nginx 部署vue 多前端
──
版本:V1.0 日期:2021-09-18
#文档密级:一级#

xxx
版权归属所有

[TOC]

route

https://router.vuejs.org/zh/api/#Functions-createRouter

import.meta.env.VITE_QC_API_URL

1
2
3
4
export const router = createRouter({
history: createWebHashHistory(import.meta.env.VITE_QC_API_URL),
routes: [...notFoundAndNoPower, ...staticRoutes],
});

webapck

https://cli.vuejs.org/zh/config/#vue-config-js#baseUrl[#](https://cli.vuejs.org/zh/config/#baseurl)

从 Vue CLI 3.3 起已弃用,请使用publicPath

vue.config.js

1
2
3
4
5
module.exports = {
baseUrl: process.env.NODE_ENV === 'production'
? '/production-sub-path/'
: '/'
}
1
2
3
4
5
module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? '/production-sub-path/'
: '/'
}

vite

https://cn.vitejs.dev/config/shared-options.html#base

vite.config.ts

1
2
3
{
base: mode.command === 'serve' ? './' : '/',
}

nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
server {
listen 9996;
server_name _;
charset utf-8;
#ssl_certificate cert/server.pem;
#ssl_certificate_key cert/server.key;
#ssl_session_timeout 5m;
#ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
#ssl_prefer_server_ciphers on;
#error_page 497 https://$host:$server_port$uri$is_args$args;

# hash 模式
location /qqq {
alias D:/work/vscode/password-evaluation-html/dist; #在匹配到的路径前面,增加root基础路径配置
try_files $uri $uri/ /index.html; # 特定目录,匹配不到文件的话,增加/lily/index.html配置
index index.html index.htm;
}

# history 模式
location /aaa {
# root D://work/vscode/marvel-service-html-v3-demo/dist; 不行
alias D://work/vscode/marvel-service-html-v3-demo/dist;
try_files $uri $uri/ /aaa/index.html;
index index.html index.htm;
}


}
The End