vue.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 = '192.168.2.2'
  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. // 配置css前缀,px转rem
  19. css: {
  20. loaderOptions: {
  21. less: {
  22. modifyVars: {
  23. hack: `true; @import "${themePath}";`
  24. }
  25. },
  26. postcss: {
  27. plugins: [
  28. autoprefixer(),
  29. pxtorem({
  30. rootValue: 37.5,
  31. propList: ["*"]
  32. })
  33. ]
  34. }
  35. }
  36. },
  37. configureWebpack: {
  38. externals: {
  39. axios: "axios" // 配置使用CDN
  40. }
  41. },
  42. devServer: {
  43. open: true, //是否自动弹出浏览器页面
  44. port: '10087',
  45. https: false,
  46. hotOnly: false,
  47. // 代理
  48. proxy: {
  49. // 只要请求地址有'api'都会匹配上
  50. "/api": {
  51. target: "http://"+ip+":10010",
  52. ws: true,
  53. // 允许跨域
  54. changeOrigin: true,
  55. pathRewrite: {
  56. "^/api": "" //通过pathRewrite重写地址,将前缀/api转为/
  57. }
  58. }
  59. }
  60. }
  61. };