vue.config.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. // var ip = '127.0.0.1'
  6. // var ip = '192.168.2.105'
  7. var ip = '47.100.37.243'
  8. // var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
  9. // for (var i in ifaces) {
  10. // for (var j in ifaces[i]) {
  11. // var val = ifaces[i][j]
  12. // if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
  13. // ip = val.address
  14. // }
  15. // }
  16. // }
  17. module.exports = {
  18. // 关闭eslint检查
  19. lintOnSave: false,
  20. // 配置css前缀,px转rem
  21. css: {
  22. loaderOptions: {
  23. less: {
  24. modifyVars: {
  25. hack: `true; @import "${themePath}";`
  26. }
  27. },
  28. postcss: {
  29. plugins: [
  30. autoprefixer(),
  31. pxtorem({
  32. rootValue: 37.5,
  33. propList: ["*"]
  34. })
  35. ]
  36. }
  37. }
  38. },
  39. configureWebpack: {
  40. externals: {
  41. axios: "axios" // 配置使用CDN
  42. }
  43. },
  44. devServer: {
  45. open: true, //是否自动弹出浏览器页面
  46. port: '10087',
  47. https: false,
  48. hotOnly: false,
  49. // 代理
  50. proxy: {
  51. // 只要请求地址有'api'都会匹配上
  52. "/api": {
  53. target: "http://"+ip+":10010",
  54. ws: true,
  55. // 允许跨域
  56. changeOrigin: true,
  57. pathRewrite: {
  58. "^/api": "" //通过pathRewrite重写地址,将前缀/api转为/
  59. }
  60. }
  61. },
  62. }
  63. };