vite.config.ts 1.6 KB

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