mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
移除 `json-viewer-js` 和 `vuex` 等未使用的依赖,减少项目体积。优化 `vite.config.js` 中的打包配置,增加手动分包功能以提升构建性能。同时,将登录页面的组件改为动态导入,减少初始加载时间。
54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
import { defineConfig, loadEnv } from "vite";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import { resolve } from "path";
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ command, mode }) => {
|
|
const env = loadEnv(mode, process.cwd());
|
|
return {
|
|
// 设置scss的api类型为modern-compiler
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
api: 'modern-compiler'
|
|
}
|
|
}
|
|
},
|
|
|
|
plugins: [vue()],
|
|
server: {
|
|
host: "0.0.0.0",
|
|
port: 5180,
|
|
proxy: {
|
|
[env.VITE_APP_BASE_API]: {
|
|
target: env.VITE_API_BASE_URL,
|
|
secure: false, // 请求是否为https
|
|
changeOrigin: true, // 是否跨域
|
|
// rewrite: (path) => path.replace(/^\/api/, '')
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
// 设置路径
|
|
'~': resolve(__dirname, './'),
|
|
// 设置别名
|
|
'@': resolve(__dirname, './src')
|
|
},
|
|
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
|
},
|
|
build: {
|
|
chunkSizeWarningLimit: 1600, // 打包文件大小限制
|
|
rollupOptions: { // 打包配置
|
|
output: { //
|
|
manualChunks(id) { // 手动分包
|
|
if (id.includes('node_modules')) {
|
|
return id.toString().split('node_modules/')[1].split('/')[0].toString(); // 根据node_modules中的包名进行分包
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
};
|
|
});
|