vue.config.js 2.1 KB

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