Files
hongshu-web/vite.config.ts
2024-07-03 16:56:33 +08:00

50 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
import { resolve } from "path";
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
"@": resolve(__dirname, "./src"),
},
//extensions: [".ts", ".js", ".vue", ".json", ".mjs"],
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
},
// server: {
// port: 3000,
// open: true,
// // 配置代理
// proxy: {
// // 请求的路径前缀只要是 /testaxios 就会被拦截走这个代理
// '/oss': {
// /**
// * 请求的目标资源再经过替换成 /httphwm/getList 后,
// * 会加上 http://127.0.0.1:9693 这个前缀,
// * 最后请求的URL为: http://127.0.0.1:9693/httphwm/getList
// */
// target: 'http://localhost:8080/',
// ws: true,
// changeOrigin: true,
// // 拦截到的请求路径 testaxios/httphwm/getList/testaxios会被替换成空
// rewrite: (path) => path.replace(/^\/oss/, 'oss'),
// },
// },
// }
server: {
port: 80,
host: true,
open: true,
proxy: {
// https://cn.vitejs.dev/config/#server-proxy
'/dev-api': {
target: 'http://localhost:8080',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '')
}
}
},
});