import { fileURLToPath, URL } from 'node:url' import { extname } from 'node:path' import { defineConfig, splitVendorChunkPlugin } from 'vite' import vue from '@vitejs/plugin-vue' import legacy from '@vitejs/plugin-legacy' export default defineConfig({ plugins: [ vue(), splitVendorChunkPlugin(), legacy({ targets: ['Android >= 5', 'Chrome >= 64'], modernPolyfills: true, additionalLegacyPolyfills: ['regenerator-runtime/runtime'] }) ], assetsInclude: ['/static/qm/three.js', '/static/qm/MainMap_QM.js'], base: './', build: { sourcemap: true, cssTarget: 'chrome61', rollupOptions: { output: { chunkFileNames: 'js/[name].[hash].js', entryFileNames: 'js/[name].[hash].js', assetFileNames: chunkInfo => { let subDir = 'images' if (extname(chunkInfo.name as string) === '.css') { subDir = 'css' } else if (extname(chunkInfo.name as string) === '.ttf') { subDir = 'font' } return `assets/${subDir}/[name].[hash].[ext]` } } } }, resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } } })