6 Star 63 Fork 23

Lyp/van

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
Lyp 提交于 2023-06-13 22:15 . feat: 代码优化
import { defineConfig, loadEnv } from 'vite'
import { createVitePlugins } from "./build/vite/plugins"
import { resolve } from "path";
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const root: string = process.cwd();
const env: Record<string, string> = loadEnv(mode, root);
const isBuild: boolean = command === 'build';
console.log("command", command)
console.log("mode", mode)
console.log("env", env)
return {
build: {
target: ["chrome91"],
sourcemap: true,
minify: false,
},
plugins: createVitePlugins(env, isBuild),
resolve: {
alias: [
// @/xxxx => src/xxxx
{
find: '@',
replacement: resolve(process.cwd(), '.', 'src') + '/',
},
// /#/xxxx => types/xxxx
{
find: '#',
replacement: resolve(process.cwd(), '.', 'types') + '/',
},
]
},
server: {
host: "0.0.0.0",
port: 3003,
proxy: {
[env.VITE_BASE_URL]: {
secure: false,
target: env.VITE_ORIGIN,
rewrite(path: string) {
if (env['VITE_KEEP_API_PREFIX'] !== 'yes') {
return path.replace(env.VITE_BASE_URL, '')
}
return path
},
headers: {
Origin: env.VITE_ORIGIN,
},
}
}
},
};
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/L1yp/van.git
git@gitee.com:L1yp/van.git
L1yp
van
van
dev

搜索帮助

0d507c66 1850385 C8b1a773 1850385