vue.config.1.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. const path = require('path')
  2. // 拼接路径
  3. function resolve (dir) {
  4. return path.join(__dirname, dir)
  5. }
  6. // 基础路径 注意发布之前要先修改这里
  7. let baseUrl = '/'
  8. // 演示项目自动构建使用
  9. if (process.env.VUE_APP_TRAVIS === 'TRUE') baseUrl = '/enrol/'
  10. module.exports = {
  11. baseUrl: baseUrl, // 根据你的实际情况更改这里
  12. lintOnSave: true,
  13. devServer: {
  14. publicPath: baseUrl, // 和 baseUrl 保持一致
  15. proxy:{
  16. '/StdUpload/':{
  17. target: 'http://qmth.hmsoft.cn/',
  18. },
  19. '/ExamCate/':{
  20. target: 'http://qmth.hmsoft.cn/',
  21. },
  22. '/CertPhoto/':{
  23. target: 'http://qmth.hmsoft.cn/',
  24. },
  25. '/frame/':{
  26. target: 'http://qmth.hmsoft.cn/',
  27. },
  28. '/enrol/': {
  29. target: 'http://qmth.hmsoft.cn/',
  30. // target: 'http://192.168.1.102:8080/hmsoft-enrol',
  31. // target: 'http://192.168.1.103:8080/hmsoft-enrol',
  32. // target: 'http://192.168.1.103:8080/hmsoft-enrol',
  33. // target: 'http://192.168.1.90:8081/hmsoft-art',
  34. // target: 'http://192.168.1.90:8081/hmsoft-art',
  35. // target: 'http://127.0.0.1:8081/bk',//设置你调用的接口域名和端口号 别忘了加http
  36. changeOrigin: true,
  37. // pathRewrite: {
  38. // '^/enrol': ''//这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替 比如我要调用'http://40.00.100.100:3002/user/add',直接写‘/api/user/add’即可
  39. // }
  40. onProxyRes(proxyRes, req, res) {
  41. var cookies = proxyRes.headers['set-cookie']
  42. if (cookies == null || cookies.length == 0) {
  43. delete proxyRes.headers['set-cookie']
  44. return
  45. }
  46. for (var i = 0,n = cookies.length; i < n; i++) {
  47. if(cookies[i].match(/^JSESSIONID=[^;]+;[\s\S]*Path=\/[^;]+/)){
  48. cookies[i] = cookies[i].replace(/Path=\/[^;]+/,'Path=/');
  49. }
  50. }
  51. proxyRes.headers['set-cookie'] = cookies;
  52. }
  53. }
  54. }
  55. },
  56. // 默认设置: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/lib/config/base.js
  57. chainWebpack: config => {
  58. // 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
  59. config.resolve
  60. .symlinks(true)
  61. // markdown
  62. config.module
  63. .rule('md')
  64. .test(/\.md$/)
  65. .use('text-loader')
  66. .loader('text-loader')
  67. .end()
  68. // i18n
  69. config.module
  70. .rule('i18n')
  71. .resourceQuery(/blockType=i18n/)
  72. .use('i18n')
  73. .loader('@kazupon/vue-i18n-loader')
  74. .end()
  75. // svg
  76. const svgRule = config.module.rule('svg')
  77. svgRule.uses.clear()
  78. svgRule
  79. .include
  80. .add(resolve('src/assets/svg-icons/icons'))
  81. .end()
  82. .use('svg-sprite-loader')
  83. .loader('svg-sprite-loader')
  84. .options({
  85. symbolId: 'd2-[name]'
  86. })
  87. .end()
  88. // image exclude
  89. const imagesRule = config.module.rule('images')
  90. imagesRule
  91. .test(/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/)
  92. .exclude
  93. .add(resolve('src/assets/svg-icons/icons'))
  94. .end()
  95. // 重新设置 alias
  96. config.resolve.alias
  97. .set('@', resolve('src'))
  98. // babel-polyfill 加入 entry
  99. const entry = config.entry('app')
  100. entry
  101. .add('babel-polyfill')
  102. .end()
  103. }
  104. }