vue.config.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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-system',
  16. productionSourceMap: false,
  17. chainWebpack: config => {
  18. // 配置别名
  19. config.resolve.alias
  20. .set('@', resolve('src'))
  21. .set('@assets', resolve('src/assets'))
  22. .set('@views', resolve('src/views'))
  23. .set('@components', resolve('src/components'))
  24. .set('@utils', resolve('src/utils'));
  25. // 配置style px->vm
  26. config.module
  27. .rule('vue')
  28. .test(/\.vue$/)
  29. .use('style-vw-loader')
  30. .loader('style-vw-loader')
  31. .options({
  32. viewportWidth: 1920,//传参
  33. })
  34. },
  35. // 配置全局样式变量
  36. css: {
  37. loaderOptions: {
  38. // sass: {
  39. // data: '@import "@/assets/styles/common/px2rem.scss";@import "@/assets/styles/common/mixins.scss";'
  40. // },
  41. // postcss: {
  42. // plugins: [
  43. // require('postcss-pxtorem')({
  44. // rootValue: 100, // 换算的基数
  45. // selectorBlackList: ['weui', 'mu'], // 忽略转换正则匹配项
  46. // propList: ['*']
  47. // })
  48. // ]
  49. // }
  50. // scss: generateLoaders('sass').concat({
  51. // loader: 'sass-resources-loader',
  52. // options: {
  53. // resources: path.relative(__dirname, '../src/assets/css/punlic-style.scss')
  54. // }
  55. // })
  56. }
  57. },
  58. configureWebpack: {
  59. externals: {
  60. vue: 'Vue',
  61. 'vue-router': 'VueRouter',
  62. vuex: 'Vuex',
  63. 'element-ui': 'ELEMENT',
  64. axios: 'axios',
  65. lodash: '_',
  66. dayjs: 'dayjs',
  67. echarts: 'echarts'
  68. }
  69. },
  70. devServer: {
  71. host: '0.0.0.0', // can be overwritten by process.env.HOST
  72. port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
  73. https: false, // https:{type:Boolean}
  74. open: false, // 配置自动启动浏览器 open: 'Google Chrome'-默认启动谷歌
  75. // 配置多个代理
  76. proxy: {
  77. '/sc-user-auth': {
  78. target: envConfig.baseApi,
  79. ws: true, // 代理的WebSockets
  80. changeOrigin: true, // 允许websockets跨域
  81. pathRewrite: {
  82. /* "^/api": "" */
  83. }
  84. },
  85. '/sc-user-center': {
  86. target: envConfig.baseApi,
  87. ws: true, // 代理的WebSockets
  88. changeOrigin: true, // 允许websockets跨域
  89. logLevel: 'debug',
  90. pathRewrite: {
  91. /* "^/api": "" */
  92. }
  93. },
  94. '/sc-community': {
  95. target: envConfig.baseApi,
  96. ws: true, // 代理的WebSockets
  97. changeOrigin: true, // 允许websockets跨域
  98. logLevel: 'debug',
  99. pathRewrite: {
  100. // "^/sc-community": ""
  101. }
  102. },
  103. '/sc-message': {
  104. target: envConfig.baseApi,
  105. ws: true, // 代理的WebSockets
  106. changeOrigin: true, // 允许websockets跨域
  107. logLevel: 'debug',
  108. pathRewrite: {
  109. /* "^/api": "" */
  110. }
  111. },
  112. '/sc-operation-manager': {
  113. target: envConfig.baseApi,
  114. ws: true, // 代理的WebSockets
  115. changeOrigin: true, // 允许websockets跨域
  116. logLevel: 'debug',
  117. pathRewrite: {
  118. /* "^/api": "" */
  119. }
  120. },
  121. '/sc-zoniot-water': {
  122. target: envConfig.baseApi,
  123. ws: true, // 代理的WebSockets
  124. changeOrigin: true, // 允许websockets跨域
  125. logLevel: 'debug',
  126. pathRewrite: {
  127. // "^/api": ""
  128. }
  129. },
  130. }
  131. },
  132. pluginOptions: {
  133. "postcss-import": {},
  134. "postcss-url": {},
  135. "postcss-aspect-ratio-mini": {},
  136. "postcss-write-svg": {
  137. utf8: false
  138. },
  139. "postcss-cssnext": {},
  140. "postcss-px-to-viewport": {
  141. viewportWidth: 1920, // 视窗的宽度,对应的是我们设计稿的宽度,移动端一般是750,如果是pc端那就是类似1920这样的尺寸
  142. viewportHeight: 1080, // 视窗的高度,移动端一般指定1334,也可以不配置
  143. unitPrecision: 3, // 指定`px`转换为视窗单位值的小数位数(很多时候无法整除)
  144. viewportUnit: 'vw', // 指定需要转换成的视窗单位,建议使用vw
  145. // selectorBlackList: ['.ignore', '.hairlines'], // 指定不转换为视窗单位的类,可以自定义,可以无限添加,建议定义一至两个通用的类名
  146. minPixelValue: 1, // 小于或等于`1px`不转换为视窗单位,你也可以设置为你想要的值
  147. mediaQuery: false // 允许在媒体查询中转换`px`
  148. },
  149. "postcss-viewport-units": {},
  150. "cssnano": {
  151. preset: "default", // 设置成default将不会启用autoprefixer
  152. "postcss-zindex": false
  153. }
  154. }
  155. };