vue.config.js 977 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const {
  2. defineConfig
  3. } = require('@vue/cli-service')
  4. const {
  5. VantResolver
  6. } = require('unplugin-vue-components/resolvers');
  7. const ComponentsPlugin = require('unplugin-vue-components/webpack');
  8. module.exports = defineConfig({
  9. transpileDependencies: true,
  10. configureWebpack: {
  11. plugins: [
  12. ComponentsPlugin({
  13. resolvers: [VantResolver()],
  14. }),
  15. ],
  16. },
  17. devServer: {
  18. // https: true,
  19. port: "8088", //代理端口
  20. open: true, //项目启动时是否自动打开浏览器,我这里设置为false,不打开,true表示打开
  21. headers: {
  22. 'Access-Control-Allow-Origin': '*',
  23. },
  24. proxy: {
  25. // https://cn.vitejs.dev/config/#server-proxy
  26. '/test-api': {
  27. target: 'http://139.9.102.170:10006',
  28. // target: 'http://139.9.102.170',
  29. changeOrigin: true,
  30. rewrite: (p) => p.replace(/^\/test-api/, '')
  31. },
  32. '/prod-api': {
  33. target: 'http://139.9.102.170',
  34. changeOrigin: true,
  35. rewrite: (p) => p.replace(/^\/prod-api/, '')
  36. }
  37. }
  38. },
  39. })