5 Star 45 Fork 14

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,
},
}
}
},
};
})
TypeScript
1
https://gitee.com/L1yp/van.git
git@gitee.com:L1yp/van.git
L1yp
van
van
dev

搜索帮助