vite.config.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { defineConfig,loadEnv } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import legacy from '@vitejs/plugin-legacy'
  4. import path from 'path'
  5. // https://vitejs.dev/config/
  6. export default ({mode})=>defineConfig({
  7. base:loadEnv(mode, process.cwd()).VITE_BASEURL,
  8. plugins: [
  9. vue(),
  10. legacy({
  11. polyfills: ['es.promise.finally', 'es/map', 'es/set'],
  12. modernPolyfills: ['es.promise.finally']
  13. })
  14. ],
  15. server: {
  16. port: 3000,
  17. cors: true,
  18. host: '0.0.0.0',
  19. proxy: {
  20. '/v1': {
  21. // target: 'http://8.136.199.33:8608',
  22. target: 'https://charttest.hzinsights.com',
  23. changeOrigin: true,
  24. rewrite: (path) => path.replace(/^\/v1/, '/v1')
  25. }
  26. },
  27. },
  28. build: {
  29. outDir: 'eta_chart_front',
  30. chunkSizeWarningLimit: 1000,//单文件过1000kb警告
  31. },
  32. resolve: {
  33. alias: {
  34. '@': path.resolve(__dirname, './src')
  35. },
  36. },
  37. css: {
  38. postcss: {
  39. plugins: [
  40. {
  41. postcssPlugin: 'internal:charset-removal',
  42. AtRule: {
  43. charset: (atRule) => {
  44. if (atRule.name === 'charset') {
  45. atRule.remove()
  46. }
  47. }
  48. }
  49. }
  50. ]
  51. }
  52. }
  53. })