更新路由以及静态页面完成
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import { type ConfigEnv, type UserConfig, loadEnv, defineConfig, PluginOption } from "vite";
|
||||
import { type ConfigEnv, type UserConfig, loadEnv, defineConfig, type PluginOption } from "vite";
|
||||
|
||||
import AutoImport from "unplugin-auto-import/vite";
|
||||
import Components from "unplugin-vue-components/vite";
|
||||
@@ -20,11 +20,12 @@ const __APP_INFO__ = {
|
||||
const pathSrc = resolve(__dirname, "src");
|
||||
|
||||
// Vite配置 https://cn.vitejs.dev/config
|
||||
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
export default defineConfig(({ mode }: ConfigEnv) => {
|
||||
const env = loadEnv(mode, process.cwd());
|
||||
const isProduction = mode === "production";
|
||||
|
||||
return {
|
||||
base: "./", // 设置为相对路径,支持直接打开index.html
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": pathSrc,
|
||||
@@ -40,15 +41,16 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
},
|
||||
server: {
|
||||
host: "0.0.0.0",
|
||||
port: +env.VITE_APP_PORT,
|
||||
port: +(env.VITE_APP_PORT as string),
|
||||
open: true,
|
||||
proxy: {
|
||||
// 代理 /dev-api 的请求
|
||||
[env.VITE_APP_BASE_API]: {
|
||||
[env.VITE_APP_BASE_API as string]: {
|
||||
changeOrigin: true,
|
||||
// 代理目标地址:https://api.youlai.tech
|
||||
target: env.VITE_APP_API_URL,
|
||||
rewrite: (path: string) => path.replace(new RegExp("^" + env.VITE_APP_BASE_API), ""),
|
||||
target: env.VITE_APP_API_URL as string,
|
||||
rewrite: (path: string) =>
|
||||
path.replace(new RegExp("^" + (env.VITE_APP_BASE_API as string)), ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -86,7 +88,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
dts: false,
|
||||
// dts: "src/types/components.d.ts",
|
||||
}),
|
||||
] as PluginOption[],
|
||||
],
|
||||
// 预加载项目必需的组件
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
@@ -192,7 +194,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||
// 构建配置
|
||||
build: {
|
||||
chunkSizeWarningLimit: 2000, // 消除打包大小超过500kb警告
|
||||
minify: isProduction ? "terser" : false, // 只在生产环境启用压缩
|
||||
minify: isProduction ? ("terser" as const) : false, // 只在生产环境启用压缩
|
||||
terserOptions: isProduction
|
||||
? {
|
||||
compress: {
|
||||
|
||||
Reference in New Issue
Block a user