build: add Vite web production pipeline
This commit is contained in:
42
frontend/vite.config.js
Normal file
42
frontend/vite.config.js
Normal 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'
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user