vite.config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * vite 配置文件
  3. */
  4. import { loadEnv } from 'vite';
  5. import { resolve } from 'path';
  6. import vue from '@vitejs/plugin-vue';
  7. import vueJsx from '@vitejs/plugin-vue-jsx';
  8. import PurgeIcons from 'vite-plugin-purge-icons';
  9. import viteCompression from 'vite-plugin-compression';
  10. import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
  11. import UnoCSS from 'unocss/vite';
  12. // https://vitejs.dev/config/
  13. export default (command, mode) => {
  14. const env = loadEnv(mode, __dirname, 'SHEEP_');
  15. return {
  16. base: './',
  17. envPrefix: 'SHEEP_',
  18. plugins: [
  19. vue(),
  20. vueJsx(),
  21. UnoCSS(),
  22. viteCompression({ verbose: false }),
  23. createSvgIconsPlugin({
  24. iconDirs: [resolve(__dirname, './src/assets/svg')],
  25. symbolId: 'sa-[dir]-[name]',
  26. }),
  27. PurgeIcons(),
  28. ],
  29. resolve: {
  30. alias: {
  31. '@': resolve(__dirname, './src'),
  32. },
  33. },
  34. css: {
  35. preprocessorOptions: {
  36. scss: {},
  37. },
  38. },
  39. server: {
  40. host: true,
  41. open: true,
  42. port: env.SHEEP_DEV_PORT,
  43. hmr: {
  44. overlay: true,
  45. },
  46. proxy: {
  47. '/mall': {
  48. target: 'http://192.168.0.101:8101/',
  49. changeOrigin: true,
  50. },
  51. '/operating': {
  52. target: 'http://192.168.0.101:8301/',
  53. changeOrigin: true,
  54. },
  55. },
  56. },
  57. build: {
  58. chunkSizeWarningLimit: 2000,
  59. sourcemap: false,
  60. },
  61. preview: {
  62. port: env.SHEEP_PREVIEW_PORT,
  63. },
  64. };
  65. };