vue.config.js 813 B

1234567891011121314151617181920212223242526272829
  1. const path = require('path')
  2. function resolve(dir) { // 配置别名
  3. return path.join(__dirname, dir)
  4. }
  5. const { defineConfig } = require('@vue/cli-service')
  6. module.exports = defineConfig({
  7. publicPath: './',
  8. transpileDependencies: true,
  9. lintOnSave: false,
  10. configureWebpack: {
  11. resolve: {
  12. alias: {
  13. '@': resolve('src')
  14. }
  15. }
  16. },
  17. devServer: {
  18. //开启代理服务器 (方式1) 配置多个代理
  19. proxy: {
  20. "/api": {
  21. //'/api'是自行设置的请求前缀
  22. target: "http://localhost:5000",
  23. // ws: true,//用于支持websocket
  24. changeOrigin: true, //用于控制请求头中的host值
  25. pathRewrite: { "^/api": "" }, //路径重写,(正则)匹配以api开头的路径为空(将请求前缀删除)
  26. },
  27. },
  28. }
  29. })