vue.config.js 2.2 KB

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