vue.config.js 2.1 KB

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