vite.config.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. import Icons from 'unplugin-icons/vite'
  12. import IconsResolver from 'unplugin-icons/resolver'
  13. export default defineConfig({
  14. // base:'/webapps/page/liankao/',
  15. resolve: {
  16. alias: {
  17. '~/': `${path.resolve(__dirname, 'src')}/`,
  18. '@': `${path.resolve(__dirname, 'src')}`,
  19. },
  20. },
  21. plugins: [
  22. VueMacros({
  23. plugins: {
  24. vue: Vue({
  25. reactivityTransform: true,
  26. }),
  27. },
  28. }),
  29. WindiCss(),
  30. // https://github.com/hannoeru/vite-plugin-pages
  31. Pages({ extensions: ['vue'] }),
  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. ],
  44. vueTemplate: true,
  45. resolvers: [ElementPlusResolver()],
  46. }),
  47. // https://github.com/antfu/vite-plugin-components
  48. Components({
  49. dts: true,
  50. resolvers: [ElementPlusResolver(), IconsResolver()],
  51. }),
  52. Icons({
  53. compiler: 'vue3',
  54. autoInstall: true,
  55. }),
  56. // https://github.com/antfu/unocss
  57. // see unocss.config.ts for config
  58. ],
  59. // https://github.com/vitest-dev/vitest
  60. test: {
  61. environment: 'jsdom',
  62. },
  63. })