vue.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. module.exports = {
  2. outputDir: 'sc',
  3. publicPath: "/sc",
  4. assetsDir: 'static',
  5. css: {
  6. extract: false
  7. },
  8. filenameHashing: true,
  9. configureWebpack: {
  10. output: {
  11. filename: '[name].[hash].js',
  12. chunkFilename: '[id].[hash].chunk.js'
  13. }
  14. },
  15. devServer: {
  16. open: true,
  17. proxy: {
  18. '/': { //前端任何含/api的URL请求都会被反向代理。如http://localhost:8000/xxx/api/source/xxx的请求会变成服务器的反向代理请求
  19. target: 'http://120.25.151.99:49011', //原来请求的服务器IP地址会换成此地址,如以上地址会变成http://localhost:5000/xxx/api/source/xxx
  20. // target: 'http://112.74.63.148:49011', //原来请求的服务器IP地址会换成此地址,如以上地址会变成http://localhost:5000/xxx/api/source/xxx
  21. changeOrigin: true, // 是否跨域
  22. pathRewrite: {
  23. // '.+?/api': '/api'
  24. } // 这里会对反向代理的地址进行重写。比如我的实际后端资源的URI是http://localhost:5000/api/resource,那么不加这个配置属性的话是访问不到我这个有效地址的。这里配置是一个正则替换,替换后就是后端api真正有效的地址了
  25. },
  26. "/weixin": {
  27. target: "https://api.weixin.qq.com/",
  28. ws: true,
  29. secure: true, // 使用的是http协议设置为 false,https协议设置为 true
  30. changeOrigin: true,
  31. pathRewrite: {
  32. "^/weixin": "",
  33. }
  34. }
  35. },
  36. disableHostCheck: true,
  37. }
  38. }