Skip to content

Commit 000b005

Browse files
committed
feat: 改用 https,加快首次打开页面
1 parent 53a9f3d commit 000b005

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

build/vite/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import viteCompression from 'vite-plugin-compression'
1414
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
1515
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
1616
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
17+
import mkcert from 'vite-plugin-mkcert'
18+
// import PkgConfig from 'vite-plugin-package-config'
19+
// import OptimizationPersist from 'vite-plugin-optimize-persist'
1720
export function createVitePlugins(VITE_APP_TITLE: string) {
1821
const root = process.cwd()
1922
// 路径查找
@@ -93,6 +96,9 @@ export function createVitePlugins(VITE_APP_TITLE: string) {
9396
}),
9497
ViteEjsPlugin({
9598
title: VITE_APP_TITLE
96-
})
99+
}),
100+
mkcert(),
101+
// PkgConfig(),
102+
// OptimizationPersist(),
97103
]
98104
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"private": false,
77
"scripts": {
88
"i": "pnpm install",
9-
"dev": "vite --mode base",
9+
"dev": "DEBUG=vite:plugin:mkcert vite --mode base --force",
1010
"ts:check": "vue-tsc --noEmit",
1111
"build:pro": "vite build --mode pro",
1212
"build:dev": "vite build --mode dev",
@@ -55,6 +55,9 @@
5555
"qs": "^6.11.0",
5656
"steady-xml": "^0.1.0",
5757
"url": "^0.11.0",
58+
"vite-plugin-mkcert": "^1.13.0",
59+
"vite-plugin-optimize-persist": "^0.1.2",
60+
"vite-plugin-package-config": "^0.1.1",
5861
"vue": "3.2.47",
5962
"vue-i18n": "9.2.2",
6063
"vue-router": "^4.1.6",

src/types/auto-imports.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ declare global {
4040
const ref: typeof import('vue')['ref']
4141
const required: typeof import('@/utils/formRules')['required']
4242
const resolveComponent: typeof import('vue')['resolveComponent']
43-
const resolveDirective: typeof import('vue')['resolveDirective']
4443
const shallowReactive: typeof import('vue')['shallowReactive']
4544
const shallowReadonly: typeof import('vue')['shallowReadonly']
4645
const shallowRef: typeof import('vue')['shallowRef']
@@ -65,3 +64,8 @@ declare global {
6564
const watchPostEffect: typeof import('vue')['watchPostEffect']
6665
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
6766
}
67+
// for type re-export
68+
declare global {
69+
// @ts-ignore
70+
export type { Component,ComponentPublicInstance,ComputedRef,InjectionKey,PropType,Ref,VNode } from 'vue'
71+
}

vite.config.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
2626
// 服务端渲染
2727
server: {
2828
// 是否开启 https
29-
https: false,
29+
https: true,
3030
// 端口号
3131
port: env.VITE_PORT,
3232
host: "0.0.0.0",
3333
open: env.VITE_OPEN === 'true',
3434
// 本地跨域代理
35-
proxy: {
36-
['/admin-api']: {
37-
target: env.VITE_BASE_URL,
38-
ws: false,
39-
changeOrigin: true,
40-
rewrite: (path) => path.replace(new RegExp(`^/admin-api`), ''),
41-
},
42-
},
35+
// proxy: {
36+
// ['/admin-api']: {
37+
// target: env.VITE_BASE_URL,
38+
// ws: false,
39+
// changeOrigin: true,
40+
// rewrite: (path) => path.replace(new RegExp(`^/admin-api`), ''),
41+
// },
42+
// },
4343
},
4444
// 项目使用的vite插件。 单独提取到build/vite/plugin中管理
4545
plugins: createVitePlugins(env.VITE_APP_TITLE),

0 commit comments

Comments
 (0)