Internal error occurred but is skipped: FindTagsByCommitIDs

Files
Situation-Awareness-Platfor…/vite.config.ts

105 lines
3.1 KiB
TypeScript

import { fileURLToPath, URL } from 'node:url';
import { defineConfig, type PluginOption, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import { visualizer } from "rollup-plugin-visualizer";
import dayjs from "dayjs";
// import basicSSL from '@vitejs/plugin-basic-ssl';
// import legacy from '@vitejs/plugin-legacy'
const fs = require('node:fs')
export default (config: any) => {
const env = loadEnv(config.mode, process.cwd());
console.log(env)
return defineConfig({
base: env.VITE_BASE_URL,
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: tag => /^micro-app/.test(tag)
}
}
}),
// // 浏览器兼容性
// legacy({
// targets: ['defaults', 'chrome >= 78', 'safari >= 14'],
// }),
visualizer({
open: config.mode === 'analysis',
}) as PluginOption,
],
server: {
host: true,
port: 443,
open: true, // 启动服务打开浏览器
headers: {
'Access-Control-Allow-Origin': '*',
},
proxy: {
// 配置跨域代理
// '/gateway/official/u-auth/index/getCaptcha': {
// // target: 'http://223.76.236.155:20011', // 目标服务器地址
// target: 'http://222.20.126.217:9700', // 目标服务器地址
// changeOrigin: true, // 允许跨域
// rewrite: (path) => path.replace('/gateway/official/u-auth', '/gateway/u-auth') // 重写路径
// },
'/api': {
// target: 'http://223.76.236.155:20011', // 目标服务器地址
target: 'http://222.20.126.217:8100', // 目标服务器地址
changeOrigin: true, // 允许跨域
rewrite: (path) => path.replace(/^\/api/, '/api'), // 重写路径
}
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import 'devui-theme/theme-collection/extend-theme-vue.scss';@import '@/assets/css/mixins/variables.scss';` // 全局引入scss文件
}
}
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
optimizeDeps: {
include: ['vue', 'dayjs', 'axios'], // 强制预构建常用包
},
build: {
outDir: 'SAP', // 将打包后的文件夹名改为 openRepoPortal
// sourcemap: config.mode !== 'production',
// 减少 chunk 大小计算,加快打包速度
reportCompressedSize: false,
// 提高超大静态资源临界值
assetsInlineLimit: 4096,
minify: 'esbuild',
// minify: 'terser', // 确保使用 terser 进行压缩
// terserOptions: {
// compress: {
// drop_console: true, // 移除 console.log
// },
// },
},
define: {
BUILD_TIME: dayjs().format('YYMMDD.HHmmss'),
},
experimental: {
renderBuiltUrl(
filename: string,
{ hostId, hostType, type }: { hostId: string, hostType: 'js' | 'css' | 'html', type: 'public' | 'asset'; }
) {
if (type === 'asset') {
// return env.VITE_STATIC_HOST + '/' + filename;
return `/SAP/${filename}`;
}
}
}
});
};