vite.config.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  8. import AutoImport from 'unplugin-auto-import/vite'
  9. import WindiCSS from 'vite-plugin-windicss'
  10. import VueMacros from 'unplugin-vue-macros/vite'
  11. export default defineConfig({
  12. resolve: {
  13. alias: {
  14. '~/': `${path.resolve(__dirname, 'src')}/`,
  15. },
  16. },
  17. plugins: [
  18. VueMacros({
  19. defineOptions: false,
  20. defineModels: false,
  21. plugins: {
  22. vue: Vue({
  23. script: {
  24. propsDestructure: true,
  25. defineModel: true,
  26. },
  27. }),
  28. },
  29. }),
  30. // https://github.com/hannoeru/vite-plugin-pages
  31. Pages(),
  32. // https://github.com/antfu/unplugin-auto-import
  33. AutoImport({
  34. imports: [
  35. 'vue',
  36. 'vue/macros',
  37. 'vue-router',
  38. '@vueuse/core',
  39. ],
  40. dts: true,
  41. dirs: [
  42. './src/composables',
  43. './src/request',
  44. './src/utils',
  45. ],
  46. vueTemplate: true,
  47. resolvers: [
  48. ElementPlusResolver(),
  49. ],
  50. }),
  51. // https://github.com/antfu/vite-plugin-components
  52. Components({
  53. dirs: ['src/components/'],
  54. // allow auto load markdown components under `./src/components/`
  55. extensions: ['vue', 'md'],
  56. // allow auto import and register components used in markdown
  57. include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
  58. resolvers: [ElementPlusResolver({ importStyle: 'sass' })],
  59. }),
  60. // https://github.com/antfu/unocss
  61. // see uno.config.ts for config
  62. WindiCSS(),
  63. ],
  64. // https://github.com/vitest-dev/vitest
  65. test: {
  66. environment: 'jsdom',
  67. },
  68. })