vite.config.ts 946 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import { resolve } from 'path'
  4. export default defineConfig({
  5. plugins: [vue()],
  6. //解决“vite use `--host` to expose”
  7. base: './',
  8. server: {
  9. proxy: {
  10. '/api': {
  11. target: 'http://192.168.11.77:8888',
  12. changeOrigin: true,
  13. rewrite: (path) => {
  14. return path.replace(/\/api/, '/api')
  15. }
  16. },
  17. '/app': {
  18. target: 'http://192.168.11.77:8080',
  19. changeOrigin: true,
  20. rewrite: (path) => {
  21. return path.replace(/\/app/, '/api')
  22. }
  23. }
  24. }
  25. },
  26. resolve: {
  27. //别名配置,引用src路径下的东西可以通过@如:import Layout from '@/layout/index.vue'
  28. alias: [
  29. {
  30. find: '@',
  31. replacement: resolve(__dirname, 'src')
  32. }
  33. ]
  34. },
  35. css: {
  36. preprocessorOptions: {
  37. scss: {
  38. api: 'modern-compiler'
  39. }
  40. },
  41. },
  42. })