vue.config.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * @Author: zouwenying
  3. * @Date: 2020-10-21 18:14:35
  4. * @LastEditTime: 2021-04-27 17:28:49
  5. * @LastEditors: zwy
  6. * @Description: In User Settings Edit
  7. * @FilePath: \vue-manage-system-master\vue.config.js
  8. */
  9. const path = require('path');
  10. const envConfig = require('./src/config');
  11. function resolve(dir) {
  12. return path.join(__dirname, dir); // path.join(__dirname)设置绝对路径
  13. }
  14. module.exports = {
  15. publicPath: '/sc-energyKb',
  16. productionSourceMap: false,
  17. lintOnSave: false,
  18. chainWebpack: config => {
  19. // 配置别名
  20. config.resolve.alias
  21. .set('@', resolve('src'))
  22. .set('@assets', resolve('src/assets'))
  23. .set('@views', resolve('src/views'))
  24. .set('@components', resolve('src/components'))
  25. .set('@utils', resolve('src/utils'));
  26. // 配置style px->vm
  27. // config.module
  28. // .rule('vue')
  29. // .test(/\.vue$/)
  30. // .use('style-vw-loader')
  31. // .loader('style-vw-loader')
  32. // .options({
  33. // viewportWidth: 1920,//传参
  34. // });
  35. // 配置每次打包浏览器缓存文件名的随机性
  36. // const filename = path.posix.join('js', `${new Date().getTime()}_[name].js`);
  37. // config.mode('production').devtool(false).output.filename(filename).chunkFilename(filename)
  38. },
  39. // // 配置全局样式变量
  40. // configureWebpack: {
  41. // externals: {
  42. // vue: 'Vue',
  43. // 'vue-router': 'VueRouter',
  44. // vuex: 'Vuex',
  45. // 'element-ui': 'ELEMENT',
  46. // axios: 'axios',
  47. // lodash: '_',
  48. // dayjs: 'dayjs',
  49. // echarts: 'echarts'
  50. // }
  51. // },
  52. devServer: {
  53. host: '0.0.0.0', // can be overwritten by process.env.HOST
  54. port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
  55. https: false, // https:{type:Boolean}
  56. open: false, // 配置自动启动浏览器 open: 'Google Chrome'-默认启动谷歌
  57. // 配置多个代理
  58. proxy: {
  59. '/sc-user-auth': {
  60. target: envConfig.baseApi,
  61. ws: true, // 代理的WebSockets
  62. changeOrigin: true, // 允许websockets跨域
  63. pathRewrite: {
  64. // "^/sc-user-auth": ""
  65. }
  66. },
  67. '/sc-user-center': {
  68. target: envConfig.baseApi,
  69. ws: true, // 代理的WebSockets
  70. changeOrigin: true, // 允许websockets跨域
  71. logLevel: 'debug',
  72. pathRewrite: {
  73. // "^/sc-user-center": ""
  74. }
  75. },
  76. '/sc-community': {
  77. target: envConfig.baseApi,
  78. ws: true, // 代理的WebSockets
  79. changeOrigin: true, // 允许websockets跨域
  80. logLevel: 'debug',
  81. pathRewrite: {
  82. // "^/sc-community": ""
  83. }
  84. },
  85. '/sc-message': {
  86. target: envConfig.baseApi,
  87. ws: true, // 代理的WebSockets
  88. changeOrigin: true, // 允许websockets跨域
  89. logLevel: 'debug',
  90. pathRewrite: {
  91. // "^/sc-message": ""
  92. }
  93. },
  94. '/sc-charge': {
  95. target: envConfig.baseApi,
  96. ws: true, // 代理的WebSockets
  97. changeOrigin: true, // 允许websockets跨域
  98. logLevel: 'debug',
  99. pathRewrite: {
  100. // "^/sc-charge": ""
  101. }
  102. },
  103. '/sc-energy': {
  104. target: envConfig.baseApi,
  105. ws: true, // 代理的WebSockets
  106. changeOrigin: true, // 允许websockets跨域
  107. logLevel: 'debug',
  108. pathRewrite: {
  109. // "^/sc-charge": ""
  110. }
  111. },
  112. '/operation-manager': {
  113. target: envConfig.baseApi,
  114. ws: true, // 代理的WebSockets
  115. changeOrigin: true, // 允许websockets跨域
  116. logLevel: 'debug',
  117. pathRewrite: {
  118. // "^/operation-manager": ""
  119. }
  120. },
  121. '/zoniot-water': {
  122. target: envConfig.baseApi,
  123. ws: true, // 代理的WebSockets
  124. changeOrigin: true, // 允许websockets跨域
  125. logLevel: 'debug',
  126. pathRewrite: {
  127. // "^/zoniot-water": ""
  128. }
  129. },
  130. }
  131. },
  132. };