vite.config.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. './src/utils',
  45. ],
  46. vueTemplate: true,
  47. }),
  48. // https://github.com/antfu/vite-plugin-components
  49. Components({
  50. dts: true,
  51. resolvers: [ElementPlusResolver(), IconsResolver()],
  52. }),
  53. // https://github.com/antfu/unocss
  54. // see uno.config.ts for config
  55. UnoCSS(),
  56. Icons({
  57. compiler: 'vue3',
  58. autoInstall: true,
  59. }),
  60. ],
  61. // https://github.com/vitest-dev/vitest
  62. test: {
  63. environment: 'jsdom',
  64. },
  65. })