vite.config.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import path from 'path'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import AutoImport from 'unplugin-auto-import/vite'
  5. import Components from 'unplugin-vue-components/vite'
  6. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  7. // import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
  8. import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
  9. // https://vitejs.dev/config/
  10. export default defineConfig({
  11. base: './',
  12. resolve: {
  13. alias: {
  14. '~/': `${path.resolve(__dirname, 'src')}/`
  15. }
  16. },
  17. css: {
  18. preprocessorOptions: {
  19. scss: {
  20. additionalData: `@use "~/styles/element/index.scss" as *;`
  21. // `@import "~/styles/index.scss";`
  22. }
  23. }
  24. },
  25. server: {
  26. proxy: {
  27. '/api': {
  28. target: 'https://vr.hdlkeji.com/api/',
  29. changeOrigin: true,
  30. rewrite: path => path.replace(/^\/api/, ''),
  31. }
  32. }
  33. },
  34. plugins: [
  35. vue(),
  36. createSvgIconsPlugin({
  37. iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
  38. symbolId: 'icon-[dir]-[name]',
  39. }),
  40. AutoImport({
  41. resolvers: [ElementPlusResolver({
  42. importStyle: "sass"
  43. })]
  44. }),
  45. Components({
  46. resolvers: [ElementPlusResolver({
  47. importStyle: "sass"
  48. })]
  49. })
  50. ]
  51. })