vite.config.ts 1.9 KB

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