vite.config.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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://www.yixiangvr.com/api/',
  29. target: 'https://vr-new.hdlkeji.com/api/',
  30. changeOrigin: true,
  31. rewrite: path => path.replace(/^\/api/, ''),
  32. }
  33. }
  34. },
  35. build: {
  36. target: 'es2020'
  37. },
  38. optimizedeps: {
  39. esbuildoptions: {
  40. target: 'es2020'
  41. }
  42. },
  43. plugins: [
  44. vue(),
  45. createSvgIconsPlugin({
  46. iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
  47. symbolId: 'icon-[dir]-[name]',
  48. }),
  49. AutoImport({
  50. resolvers: [ElementPlusResolver({
  51. importStyle: "sass"
  52. })]
  53. }),
  54. Components({
  55. resolvers: [ElementPlusResolver({
  56. importStyle: "sass"
  57. })]
  58. })
  59. ]
  60. })