Files
geo/apps/ops-web/vite.config.ts
T
root 162abdc97c
Backend CI / Backend (push) Has been cancelled
Frontend CI / Frontend (push) Failing after 1m39s
chore(frontend): introduce prettier + eslint and prune unused code
- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports)
- Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier
- Add root scripts: format, format:check, lint, lint:fix
- Reformat 257 files across admin-web, ops-web, desktop-client, packages
- Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters
- Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex
- Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 20:39:09 +08:00

71 lines
1.8 KiB
TypeScript

import { fileURLToPath, URL } from 'node:url'
import vue from '@vitejs/plugin-vue'
import { defineConfig, loadEnv, type PluginOption } from 'vite'
import { compression } from 'vite-plugin-compression2'
const r = (path: string) => fileURLToPath(new URL(path, import.meta.url))
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, '.', '')
const isProd = mode === 'production'
const plugins: PluginOption[] = [vue()]
if (isProd) {
plugins.push(
compression({
algorithms: ['gzip', 'brotliCompress'],
threshold: 1024,
}),
)
}
return {
plugins,
resolve: {
alias: {
'@': r('./src'),
},
},
server: {
host: '0.0.0.0',
port: 5174,
proxy: {
'/api': {
target: env.VITE_OPS_API_PROXY_TARGET || 'http://localhost:8090',
changeOrigin: true,
},
},
},
esbuild: isProd ? { drop: ['console', 'debugger'] } : undefined,
build: {
target: 'es2022',
sourcemap: 'hidden',
cssCodeSplit: true,
reportCompressedSize: false,
rollupOptions: {
output: {
entryFileNames: 'assets/js/[name]-[hash].js',
chunkFileNames: 'assets/js/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash][extname]',
manualChunks(id) {
if (!id.includes('node_modules')) return undefined
if (id.includes('/ant-design-vue/') || id.includes('/@ant-design/')) {
return 'antd'
}
if (
id.includes('/vue/') ||
id.includes('/@vue/') ||
id.includes('/vue-router/') ||
id.includes('/pinia/')
) {
return 'vue-vendor'
}
return 'vendor'
},
},
},
},
}
})