vue.config.js 2.1 KB

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