build: add Vite web production pipeline

This commit is contained in:
237899745
2026-07-27 13:07:10 +08:00
parent dce1e3622a
commit 6692736e88
16 changed files with 1564 additions and 22 deletions

42
frontend/vite.config.js Normal file
View File

@@ -0,0 +1,42 @@
import { readdirSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vite';
const frontendRoot = path.dirname(fileURLToPath(import.meta.url));
const htmlEntries = Object.fromEntries(
readdirSync(frontendRoot)
.filter((fileName) => fileName.endsWith('.html'))
.map((fileName) => [path.basename(fileName, '.html'), path.join(frontendRoot, fileName)])
);
export default defineConfig({
root: frontendRoot,
publicDir: false,
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js'
}
},
define: {
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
},
build: {
target: 'es2020',
outDir: 'dist',
emptyOutDir: true,
rollupOptions: {
input: htmlEntries
}
},
server: {
proxy: {
'/api': 'http://127.0.0.1:40001',
'/d': 'http://127.0.0.1:40001',
'/s': 'http://127.0.0.1:40001'
}
}
});