vue.config.js 1.7 KB

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