vue.config.js 1.8 KB

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