vite.config.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. export default defineConfig({
  12. resolve: {
  13. alias: {
  14. '~/': `${path.resolve(__dirname, 'src')}/`,
  15. '@':`${path.resolve(__dirname, 'src')}`,
  16. },
  17. },
  18. plugins: [
  19. VueMacros({
  20. plugins: {
  21. vue: Vue({
  22. reactivityTransform: true,
  23. }),
  24. },
  25. }),
  26. WindiCss(),
  27. // https://github.com/hannoeru/vite-plugin-pages
  28. Pages({extensions: ['vue']}),
  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()],
  48. }),
  49. // https://github.com/antfu/unocss
  50. // see unocss.config.ts for config
  51. ],
  52. // https://github.com/vitest-dev/vitest
  53. test: {
  54. environment: 'jsdom',
  55. },
  56. })