vite.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import VueDevTools from 'vite-plugin-vue-devtools'
  5. import VueSetupExtend from 'vite-plugin-vue-setup-extend'
  6. import autoImport from 'unplugin-auto-import/vite'
  7. import AutoImport from 'unplugin-auto-import/vite'
  8. import Components from 'unplugin-vue-components/vite'
  9. import { VantResolver } from '@vant/auto-import-resolver'
  10. const createAutoImport = () => {
  11. return autoImport({
  12. imports: ['vue', 'vue-router', 'pinia'],
  13. dts: false
  14. })
  15. }
  16. // https://vitejs.dev/config/
  17. export default defineConfig({
  18. plugins: [
  19. vue(),
  20. VueDevTools(),
  21. VueSetupExtend(),
  22. createAutoImport(),
  23. AutoImport({
  24. resolvers: [VantResolver()]
  25. }),
  26. Components({
  27. resolvers: [VantResolver()]
  28. })
  29. ],
  30. resolve: {
  31. alias: {
  32. '@': fileURLToPath(new URL('./src', import.meta.url))
  33. }
  34. },
  35. server: {
  36. host: true
  37. },
  38. //配置sass
  39. css: {
  40. preprocessorOptions: {
  41. scss: {
  42. additionalData:
  43. '@import "./src/assets/scss/globalVar.scss";@import "./src/assets/scss/globalMixin.scss";'
  44. }
  45. }
  46. }
  47. })