build(projects): 添加vercel打包的环境
This commit is contained in:
parent
a090d398fc
commit
371fad4f26
@ -7,6 +7,7 @@
|
|||||||
"typecheck": "vue-tsc --noEmit",
|
"typecheck": "vue-tsc --noEmit",
|
||||||
"build": "npm run typecheck && cross-env VITE_HTTP_ENV=prod vite build",
|
"build": "npm run typecheck && cross-env VITE_HTTP_ENV=prod vite build",
|
||||||
"build:test": "npm run typecheck && cross-env VITE_HTTP_ENV=test vite build",
|
"build:test": "npm run typecheck && cross-env VITE_HTTP_ENV=test vite build",
|
||||||
|
"build:vercel": "npm run typecheck && cross-env VITE_HTTP_ENV=prod VITE_IS_VERCEL=1 vite build",
|
||||||
"preview": "vite preview --port 5050",
|
"preview": "vite preview --port 5050",
|
||||||
"lint": "eslint --fix ./ --ext .vue,.js,jsx,.ts,tsx",
|
"lint": "eslint --fix ./ --ext .vue,.js,jsx,.ts,tsx",
|
||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import type { App } from 'vue';
|
import type { App } from 'vue';
|
||||||
import { createRouter, createWebHistory } from 'vue-router';
|
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
|
||||||
import { transformAuthRoutesToVueRoutes } from '@/utils';
|
import { transformAuthRoutesToVueRoutes } from '@/utils';
|
||||||
import { constantRoutes } from './routes';
|
import { constantRoutes } from './routes';
|
||||||
import { createRouterGuard } from './guard';
|
import { createRouterGuard } from './guard';
|
||||||
|
|
||||||
|
const createHistoryFunc = import.meta.env.VITE_IS_VERCEL === '1' ? createWebHashHistory : createWebHistory;
|
||||||
|
|
||||||
export const router = createRouter({
|
export const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createHistoryFunc(import.meta.env.BASE_URL),
|
||||||
routes: transformAuthRoutesToVueRoutes(constantRoutes),
|
routes: transformAuthRoutesToVueRoutes(constantRoutes),
|
||||||
scrollBehavior: () => ({ left: 0, top: 0 })
|
scrollBehavior: () => ({ left: 0, top: 0 })
|
||||||
});
|
});
|
||||||
|
2
src/typings/common/env.d.ts
vendored
2
src/typings/common/env.d.ts
vendored
@ -18,6 +18,8 @@ interface ImportMetaEnv {
|
|||||||
readonly VITE_APP_DESC: string;
|
readonly VITE_APP_DESC: string;
|
||||||
/** 网路请求环境类型 */
|
/** 网路请求环境类型 */
|
||||||
readonly VITE_HTTP_ENV: Service.HttpEnv;
|
readonly VITE_HTTP_ENV: Service.HttpEnv;
|
||||||
|
/** 是否是部署vercel */
|
||||||
|
readonly VITE_IS_VERCEL?: '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
|
Loading…
Reference in New Issue
Block a user