import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import legacy from '@vitejs/plugin-legacy' import path from 'path' // https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue(), legacy({ polyfills: ['es.promise.finally', 'es/map', 'es/set'], modernPolyfills: ['es.promise.finally'] }) ], server: { port: 3000, cors: true, host: '0.0.0.0', proxy: { '/v1': { // target: 'http://8.136.199.33:8608', target: 'https://charttest.hzinsights.com', changeOrigin: true, rewrite: (path) => path.replace(/^\/v1/, '/v1') } }, }, build: { outDir: 'horz_chart', chunkSizeWarningLimit: 800,//单文件过800kb警告 rollupOptions: { output: { manualChunks(id) { if (id.includes('node_modules')) { return id.toString() .split('node_modules/')[1] .split('/')[0] .toString(); } }, chunkFileNames: (info) => { const facadeModuleId = info.facadeModuleId ? info.facadeModuleId.split('/') : []; const fileName = facadeModuleId[facadeModuleId.length -2] || '[name]' return `js/${fileName}/[name].[hash].js`; } } } }, resolve: { alias: { '@': path.resolve(__dirname, './src') }, }, css: { postcss: { plugins: [ { postcssPlugin: 'internal:charset-removal', AtRule: { charset: (atRule) => { if (atRule.name === 'charset') { atRule.remove() } } } } ] } } })