vite.config.ts 1.6 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 WindiCss from 'vite-plugin-windicss'
  6. import Pages from 'vite-plugin-pages'
  7. import Components from 'unplugin-vue-components/vite'
  8. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  9. import AutoImport from 'unplugin-auto-import/vite'
  10. import VueMacros from 'unplugin-vue-macros/vite'
  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. '@': `${path.resolve(__dirname, 'src')}`,
  18. },
  19. },
  20. plugins: [
  21. VueMacros({
  22. plugins: {
  23. vue: Vue({
  24. reactivityTransform: true,
  25. }),
  26. },
  27. }),
  28. WindiCss(),
  29. // https://github.com/hannoeru/vite-plugin-pages
  30. Pages({ extensions: ['vue'] }),
  31. // https://github.com/antfu/unplugin-auto-import
  32. AutoImport({
  33. imports: [
  34. 'vue',
  35. 'vue/macros',
  36. 'vue-router',
  37. '@vueuse/core',
  38. ],
  39. dts: true,
  40. dirs: [
  41. './src/composables',
  42. ],
  43. vueTemplate: true,
  44. resolvers: [ElementPlusResolver()],
  45. }),
  46. // https://github.com/antfu/vite-plugin-components
  47. Components({
  48. dts: true,
  49. resolvers: [ElementPlusResolver(), IconsResolver()],
  50. }),
  51. Icons({
  52. compiler: 'vue3',
  53. autoInstall: true,
  54. }),
  55. // https://github.com/antfu/unocss
  56. // see unocss.config.ts for config
  57. ],
  58. // https://github.com/vitest-dev/vitest
  59. test: {
  60. environment: 'jsdom',
  61. },
  62. })