index.js 1.7 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: true,
  19. productionGzip: false,
  20. productionGzipExtensions: ['js', 'css'],
  21. bundleAnalyzerReport: process.env.npm_config_report
  22. },
  23. dev: {
  24. env: require('./dev.env'),
  25. port: 8001,
  26. autoOpenBrowser: true,
  27. assetsSubDirectory: 'static',
  28. assetsPublicPath: '/',
  29. proxyTable: {
  30. '/api': {
  31. target: 'http://'+ ip +':9099', // 接口域名 开发
  32. secure: true, // 如果是https接口,需要配置这个参数
  33. changeOrigin: true, //是否跨域
  34. pathRewrite: { // 如果接口本身没有api的路径,那么这里将发送到后端的请求重写为没有api的路径
  35. '^/api': '/'
  36. }
  37. },
  38. '/ips': {
  39. target: 'http://'+ ip +':8080', // 接口域名 开发
  40. secure: true, // 如果是https接口,需要配置这个参数
  41. changeOrigin: true, //是否跨域
  42. pathRewrite: { // 如果接口本身没有api的路径,那么这里将发送到后端的请求重写为没有api的路径
  43. '^/ips': '/'
  44. }
  45. },
  46. },
  47. cssSourceMap: false
  48. }
  49. }