vite.config.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 WindiCSS from 'vite-plugin-windicss'
  9. import VueMacros from 'unplugin-vue-macros/vite'
  10. import { VantResolver } from 'unplugin-vue-components/resolvers'
  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. ],
  55. }),
  56. // https://github.com/antfu/vite-plugin-components
  57. Components({
  58. dirs: ['src/components/'],
  59. // allow auto load markdown components under `./src/components/`
  60. extensions: ['vue', 'md'],
  61. // allow auto import and register components used in markdown
  62. include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
  63. resolvers: [VantResolver()],
  64. }),
  65. // https://github.com/antfu/unocss
  66. // see uno.config.ts for config
  67. WindiCSS(),
  68. ],
  69. // https://github.com/vitest-dev/vitest
  70. test: {
  71. environment: 'jsdom',
  72. },
  73. })