vue.config.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. const autoprefixer = require("autoprefixer");
  2. const pxtorem = require("postcss-pxtorem");
  3. const path = require('path');
  4. const themePath = path.resolve(__dirname,'src/assets/style/theme.less');
  5. const webpack = require('webpack');
  6. var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
  7. for (var i in ifaces) {
  8. for (var j in ifaces[i]) {
  9. var val = ifaces[i][j]
  10. if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
  11. ip = val.address
  12. }
  13. }
  14. }
  15. module.exports = {
  16. // 关闭eslint检查
  17. lintOnSave: false,
  18. configureWebpack: {
  19. plugins: [
  20. new webpack.ProvidePlugin({
  21. $:"jquery",
  22. jQuery:"jquery",
  23. "windows.jQuery":"jquery"
  24. })
  25. ]
  26. },
  27. // 配置css前缀,px转rem
  28. css: {
  29. loaderOptions: {
  30. less: {
  31. modifyVars: {
  32. hack: `true; @import "${themePath}";`
  33. }
  34. },
  35. postcss: {
  36. plugins: [
  37. autoprefixer(),
  38. pxtorem({
  39. rootValue: 37.5,
  40. propList: ["*"]
  41. })
  42. ]
  43. }
  44. }
  45. },
  46. configureWebpack: {
  47. externals: {
  48. axios: "axios" // 配置使用CDN
  49. }
  50. },
  51. devServer: {
  52. open: true, //是否自动弹出浏览器页面
  53. port: '10087',
  54. https: false,
  55. hotOnly: false,
  56. //disableHostCheck: true,
  57. // 代理
  58. proxy: {
  59. '/wxcorp': {
  60. target: 'http://localhost:9099/',
  61. },
  62. '/api': {
  63. target: 'http://localhost:9099/',
  64. pathRewrite: { '^/api': '' }
  65. },
  66. '/upload': {
  67. target: 'http://localhost:8010/',
  68. pathRewrite: { '^/upload': '' }
  69. },
  70. // '/weixin': {
  71. // target: 'http://localhost:8001/'
  72. // }
  73. // // 只要请求地址有'api'都会匹配上
  74. // "/api": {
  75. // target: "http://"+ip+":2021",
  76. // ws: true,
  77. // // 允许跨域
  78. // changeOrigin: true,
  79. // pathRewrite: {
  80. // "^/api": "" //通过pathRewrite重写地址,将前缀/api转为/
  81. // }
  82. // }
  83. }
  84. }
  85. };