vite.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /// <reference types="vitest" />
  2. import path from 'node:path'
  3. import { defineConfig } from 'vite'
  4. import Vue from '@vitejs/plugin-vue'
  5. import Pages from 'vite-plugin-pages'
  6. import Components from 'unplugin-vue-components/vite'
  7. import AutoImport from 'unplugin-auto-import/vite'
  8. import UnoCSS from 'unocss/vite'
  9. import VueMacros from 'unplugin-vue-macros/vite'
  10. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  11. import Icons from 'unplugin-icons/vite'
  12. import IconsResolver from 'unplugin-icons/resolver'
  13. export default defineConfig({
  14. resolve: {
  15. alias: {
  16. '~/': `${path.resolve(__dirname, 'src')}/`,
  17. },
  18. },
  19. plugins: [
  20. VueMacros({
  21. plugins: {
  22. vue: Vue({
  23. reactivityTransform: true,
  24. }),
  25. },
  26. }),
  27. // https://github.com/hannoeru/vite-plugin-pages
  28. Pages(),
  29. // https://github.com/antfu/unplugin-auto-import
  30. AutoImport({
  31. imports: [
  32. 'vue',
  33. 'vue/macros',
  34. 'vue-router',
  35. '@vueuse/core',
  36. ],
  37. dts: true,
  38. dirs: [
  39. './src/composables',
  40. ],
  41. vueTemplate: true,
  42. resolvers: [ElementPlusResolver()],
  43. }),
  44. // https://github.com/antfu/vite-plugin-components
  45. Components({
  46. dts: true,
  47. resolvers: [ElementPlusResolver(), IconsResolver()],
  48. }),
  49. // https://github.com/antfu/unocss
  50. // see uno.config.ts for config
  51. UnoCSS(),
  52. Icons({
  53. compiler: 'vue3',
  54. autoInstall: true,
  55. }),
  56. ],
  57. // https://github.com/vitest-dev/vitest
  58. test: {
  59. environment: 'jsdom',
  60. },
  61. })