init: laimiao-web-new

This commit is contained in:
light committed 2026-11-07 10:43:06 +08:00
commit c226cf7054
122 files changed
+18458

No files matched your search

+85
View File
@@ -0,0 +1,85 @@
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath, URL } from 'node:url'
import tailwindcss from '@tailwindcss/vite'
import vue from '@vitejs/plugin-vue'
import { defineConfig, loadEnv, type Plugin } from 'vite'
// 支持 /generate、/me、/library 这类不带 .html 的页面地址(dev 与 preview)
function extensionlessHtmlPlugin(root: string): Plugin {
const rewrite = (
req: { url?: string },
_res: unknown,
next: () => void,
): void => {
const url = req.url || ''
const [pathname, query] = url.split('?')
if (
pathname &&
pathname !== '/' &&
!pathname.endsWith('/') &&
!/\.[^/]+$/.test(pathname) &&
fs.existsSync(path.join(root, pathname + '.html'))
) {
req.url = pathname + '.html' + (query ? '?' + query : '')
}
next()
}
return {
name: 'extensionless-html',
configureServer(server) {
server.middlewares.use(rewrite)
},
configurePreviewServer(server) {
server.middlewares.use(rewrite)
},
}
}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const skillAgentTarget = env.VITE_SKILL_AGENT_URL || 'http://127.0.0.1:8100'
const teamApiTarget = env.VITE_TEAM_API_URL || 'https://laimiaoai.com'
const skillAgentProxy = {
'/skill-agent': {
target: skillAgentTarget,
changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/skill-agent/, ''),
},
}
const teamApiProxy = {
'/api': {
target: teamApiTarget,
changeOrigin: true,
},
}
return {
plugins: [extensionlessHtmlPlugin(process.cwd()), vue(), tailwindcss()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
port: 5181,
proxy: { ...skillAgentProxy, ...teamApiProxy },
},
preview: {
proxy: { ...skillAgentProxy, ...teamApiProxy },
},
build: {
rollupOptions: {
input: {
index: 'index.html',
app: 'app.html',
generate: 'generate.html',
me: 'me.html',
login: 'login/index.html',
invite: 'invite/index.html',
library: 'library.html',
},
},
},
}
})