vite.config.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 defineConfig(({mode})=>{
  7. const ENV = loadEnv(mode, process.cwd());
  8. return {
  9. base:ENV.VITE_APP_BASE_URL, // 若服务器不是将该项目放在根目录的则 需要此设置 和服务器上同名
  10. plugins: [
  11. vue(),
  12. legacy({
  13. polyfills: ['es.promise.finally', 'es/map', 'es/set'],
  14. modernPolyfills: ['es.promise.finally']
  15. })
  16. ],
  17. server: {
  18. port: 3000,
  19. cors: true,
  20. host: '0.0.0.0',
  21. proxy: {
  22. '/v1': {
  23. // target: 'http://8.136.199.33:8608',
  24. target: 'https://charttest.hzinsights.com',
  25. changeOrigin: true,
  26. rewrite: (path) => path.replace(/^\/v1/, '/v1')
  27. }
  28. },
  29. },
  30. build: {
  31. outDir: 'eta_chart_front',
  32. chunkSizeWarningLimit: 1000,//单文件过1000kb警告
  33. },
  34. resolve: {
  35. alias: {
  36. '@': path.resolve(__dirname, './src')
  37. },
  38. },
  39. css: {
  40. postcss: {
  41. plugins: [
  42. {
  43. postcssPlugin: 'internal:charset-removal',
  44. AtRule: {
  45. charset: (atRule) => {
  46. if (atRule.name === 'charset') {
  47. atRule.remove()
  48. }
  49. }
  50. }
  51. }
  52. ]
  53. }
  54. }
  55. }
  56. })