1 Star 0 Fork 91

angelCopy/PureChat

forked from yongkang/PureChat 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.js 2.24 KB
一键复制 编辑 原始数据 按行查看 历史
yongkang 提交于 2024-08-14 17:57 . 更新依赖
import { resolve } from "path";
import { defineConfig, loadEnv } from "vite";
import { setupVitePlugins, viteDefine } from "./build";
/** 路径查找 */
const pathResolve = (dir) => {
return resolve(__dirname, ".", dir);
};
export default defineConfig(({ mode }) => {
const viteEnv = loadEnv(mode, process.cwd());
return {
base: viteEnv.VITE_BASE_URL,
define: viteDefine,
resolve: {
/** 设置别名 */
alias: {
"@": pathResolve("src"),
"~": pathResolve("./"),
}
},
server: {
// 端口号
port: viteEnv.VITE_PORT,
open: true,
host: "0.0.0.0",
// 本地跨域代理 https://cn.vitejs.dev/config/server-options.html#server-proxy
proxy: {},
// 预热文件以提前转换和缓存结果,降低启动期间的初始页面加载时长并防止转换瀑布
warmup: {
clientFiles: ["./index.html", "./src/{views,components}/*"]
}
},
plugins: setupVitePlugins(viteEnv),
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "./src/styles/mixin.scss" as *;`,
},
},
},
// https://cn.vitejs.dev/config/dep-optimization-options.html#dep-optimization-options
optimizeDeps: {
// include,
// exclude,
},
build: {
// https://cn.vitejs.dev/guide/build.html#browser-compatibility
// target: "es2015",
// 生成生产源映射
sourcemap: viteEnv.VITE_SOURCE_MAP === "Y",
// 消除打包大小超过500kb警告
chunkSizeWarningLimit: 4000,
rollupOptions: {
input: {
index: pathResolve("index.html"),
},
// 静态资源分类打包
output: {
chunkFileNames: "static/js/[name]-[hash].js",
entryFileNames: "static/js/[name]-[hash].js",
// #https://cn.rollupjs.org/configuration-options/#output-assetfilenames
assetFileNames: "static/[ext]/[name]-[hash].[ext]",
// 手动分包 #https://cn.rollupjs.org/configuration-options/#output-manualchunks
manualChunks(id) {
if (id.includes('node_modules')) return 'vendor';
},
},
},
// 启用/ 禁用 gzip 压缩大小报告
reportCompressedSize: false,
},
};
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/angelCopy/PureChat.git
git@gitee.com:angelCopy/PureChat.git
angelCopy
PureChat
PureChat
main

搜索帮助