vite.config.mts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { defineConfig } from '@vben/vite-config';
  2. // 自行取消注释来启用按需导入功能
  3. // import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
  4. // import Components from 'unplugin-vue-components/vite';
  5. export default defineConfig(async () => {
  6. return {
  7. application: {},
  8. vite: {
  9. optimizeDeps: {
  10. include: [
  11. 'ant-design-vue/es/locale/zh_CN',
  12. 'ant-design-vue/es/locale/en_US',
  13. ],
  14. },
  15. plugins: [
  16. // Components({
  17. // dirs: [], // 默认会导入src/components目录下所有组件 不需要
  18. // dts: './types/components.d.ts', // 输出类型文件
  19. // resolvers: [
  20. // AntDesignVueResolver({
  21. // // 需要排除Button组件 全局已经默认导入了
  22. // exclude: ['Button'],
  23. // importStyle: false, // css in js
  24. // }),
  25. // ],
  26. // }),
  27. ],
  28. server: {
  29. proxy: {
  30. '/api': {
  31. changeOrigin: true,
  32. rewrite: (path) => path.replace(/^\/api/, ''),
  33. // mock代理目标地址
  34. target: 'http://localhost:8080',
  35. ws: true,
  36. },
  37. },
  38. warmup: {
  39. clientFiles: ['./index.html', './src/{views,components}/*'],
  40. },
  41. },
  42. },
  43. };
  44. });