index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var path = require('path')
  2. var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
  3. for (var i in ifaces) {
  4. for (var j in ifaces[i]) {
  5. var val = ifaces[i][j]
  6. if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
  7. ip = val.address
  8. }
  9. }
  10. }
  11. module.exports = {
  12. build: {
  13. env: require('./prod.env'),
  14. index: path.resolve(__dirname, '../dist/index.html'),
  15. assetsRoot: path.resolve(__dirname, '../dist'),
  16. assetsSubDirectory: 'static',
  17. assetsPublicPath: './',
  18. productionSourceMap: false,
  19. productionGzip: false,
  20. productionGzipExtensions: ['js', 'css'],
  21. bundleAnalyzerReport: process.env.npm_config_report
  22. },
  23. dev: {
  24. env: require('./dev.env'),
  25. port: 8070,
  26. autoOpenBrowser: true,
  27. assetsSubDirectory: 'static',
  28. assetsPublicPath: '/',
  29. proxyTable: {
  30. '/api': {
  31. // target: 'http://'+ ip +':8091', // 接口域名 开发
  32. target: 'http://'+ ip +':8091', // 接口域名 开发
  33. secure: true, // 如果是https接口,需要配置这个参数
  34. changeOrigin: true, //是否跨域
  35. pathRewrite: { // 如果接口本身没有api的路径,那么这里将发送到后端的请求重写为没有api的路径
  36. '^/api': '/'
  37. }
  38. },
  39. '/ips': {
  40. target: 'http://'+ ip +':8095', // 接口域名 开发
  41. secure: true, // 如果是https接口,需要配置这个参数
  42. changeOrigin: true, //是否跨域
  43. pathRewrite: { // 如果接口本身没有api的路径,那么这里将发送到后端的请求重写为没有api的路径
  44. '^/ips': '/'
  45. }
  46. },
  47. },
  48. cssSourceMap: false
  49. }
  50. }