refactor: frontend TS migration + Tailwind4/daisyUI5 unify + BUILDPLATFORM docker build
- migrate frontend to TypeScript (vue-tsc strict in build), upgrade all deps to latest (Vite 8, Tailwind 4, daisyUI 5, Pinia 4, vue-router 5) - restructure frontend dirs (api/components/common/layouts/styles/types/views) - drop Element Plus, add daisyUI TagInput; main CSS 490KB->163KB, entry JS 618KB->1.3KB - rewrite Dockerfile(.cn): frontend/backend stages pinned to $BUILDPLATFORM, CGO_ENABLED=0 cross-compile, no QEMU in multi-arch builds; add .dockerignore - local dev: Vite /api proxy + make dev targets; go:embed all:dist with .gitkeep so backend runs without prior frontend build - fix latent bugs: Keys.vue users ref, Settings.vue undefined userStore, Login.vue Ref-as-error display, res.error misuse - add REFACTOR_PLAN.md (phased refactor log)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
import basicSsl from '@vitejs/plugin-basic-ssl'; // 推荐使用这个插件简化自签名证书管理
|
||||
|
||||
import path from 'path'
|
||||
|
||||
// 本地开发默认走 HTTP(localhost 属于安全上下文,clipboard/passkey 均可用);
|
||||
// 需要自签名 HTTPS 时设置 VITE_DEV_HTTPS=true
|
||||
const useHttps = process.env.VITE_DEV_HTTPS === 'true'
|
||||
// 后端地址:默认 make dev-backend 启动的 8080,可用 VITE_DEV_API_TARGET 覆盖
|
||||
const apiTarget = process.env.VITE_DEV_API_TARGET || 'http://localhost:8080'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue(), tailwindcss(), ...(useHttps ? [basicSsl()] : [])],
|
||||
server: {
|
||||
https: useHttps ? {} : undefined,
|
||||
host: 'localhost', // 确保 host 是 localhost
|
||||
port: 5173,
|
||||
proxy: {
|
||||
// 前端 axios baseURL 为 /api,开发时代理到本地 Go 后端,免去跨域与重建
|
||||
'/api': {
|
||||
target: apiTarget,
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(import.meta.dirname, 'src'),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
// sourcemap: true,
|
||||
chunkSizeWarningLimit: 1000,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.includes('src/components')) {
|
||||
return 'components';
|
||||
}
|
||||
|
||||
if (id.includes('src/views/dashboard')) {
|
||||
return 'views-dashboard'
|
||||
}
|
||||
|
||||
if (id.includes('src/stores')) {
|
||||
return 'stores';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user