vite.config.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { resolve } from 'path'
  2. import vue from '@vitejs/plugin-vue'
  3. import type { UserConfig } from 'vite'
  4. import { loadEnv } from './build/utils'
  5. import { createProxy } from './build/proxy'
  6. const pathResolve = (dir: string): any => {
  7. return resolve(__dirname, '.', dir)
  8. }
  9. const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_OPEN } = loadEnv()
  10. const alias: Record<string, string> = {
  11. '/@': pathResolve('src'),
  12. }
  13. const root: string = process.cwd()
  14. const viteConfig: UserConfig = {
  15. /**
  16. * 基本公共路径
  17. * @default '/'
  18. */
  19. base: process.env.NODE_ENV === "production" ? "/manages/" : VITE_PUBLIC_PATH,
  20. root,
  21. resolve: {
  22. alias
  23. },
  24. // 服务端渲染
  25. server: {
  26. // 是否开启 https
  27. https: false,
  28. /**
  29. * 端口号
  30. * @default 3000
  31. */
  32. port: VITE_PORT,
  33. // 本地跨域代理
  34. proxy: createProxy(VITE_PROXY)
  35. },
  36. plugins: [
  37. vue(),
  38. ],
  39. build: {
  40. brotliSize: false,
  41. // 消除打包大小超过500kb警告
  42. chunkSizeWarningLimit: 800
  43. }
  44. }
  45. export default viteConfig