vite.config.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {fileURLToPath, URL} from 'node:url'
  2. import {defineConfig} from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import vueJsx from '@vitejs/plugin-vue-jsx'
  5. import vueDevTools from 'vite-plugin-vue-devtools'
  6. import svgicon from 'vite-plugin-svgicon'
  7. import * as path from 'path'
  8. // https://vite.dev/config/
  9. export default defineConfig({
  10. define: {
  11. 'process.env': {
  12. 'BASE_API': '/base_api'
  13. },
  14. },
  15. // 配置前端服务地址和端口
  16. server: {
  17. host: '0.0.0.0',
  18. port: 80,
  19. // 设置反向代理,跨域
  20. proxy: {
  21. '/tbazmw_api': {
  22. // 后台地址
  23. target: 'http://10.8.48.234:8081/',
  24. changeOrigin: true,
  25. rewrite: path => path.replace(/^\/tbazmw_api/, '')
  26. },
  27. '/gx_api': {
  28. // 共享平台
  29. target: 'http://10.8.4.136:8881/api/sz/tba-gx/',
  30. changeOrigin: true,
  31. rewrite: path => path.replace(/^\/gx_api/, '')
  32. },
  33. '/nmc_api': {
  34. // 共享平台
  35. target: 'http://www.nmc.cn/',
  36. changeOrigin: true,
  37. rewrite: path => path.replace(/^\/nmc_api/, '')
  38. },
  39. }
  40. },
  41. plugins: [
  42. vue(),
  43. vueJsx(),
  44. vueDevTools(),
  45. svgicon({
  46. include: ['**/assets/svg/*.svg'],
  47. svgFilePath: path.join(__dirname, 'src/assets/svg'),
  48. }),
  49. ],
  50. resolve: {
  51. alias: {
  52. '@': fileURLToPath(new URL('./src', import.meta.url))
  53. }
  54. },
  55. css: {
  56. preprocessorOptions: {
  57. scss: {
  58. api: "modern-compiler", // or 'modern'
  59. // 自动导入定制化样式文件进行样式覆盖
  60. // additionalData: `
  61. // @use "@/assets/styles/element/index.scss";
  62. // `,
  63. }
  64. }
  65. },
  66. })