vue.config.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. var projectname = process.argv[3];
  2. var glob = require("glob");
  3. var publicPath = ''
  4. function getEntry() {
  5. var entries = {};
  6. if (process.env.NODE_ENV == "production") {
  7. entries = {
  8. index: {
  9. // page的入口
  10. entry: "src/views/" + projectname + "/main.js",
  11. // 模板来源
  12. template: "public/index.html",
  13. // 在 dist/index.html 的输出
  14. filename: "index.html",
  15. title: projectname,
  16. chunks: ["chunk-vendors", "chunk-common", "index"]
  17. }
  18. };
  19. publicPath = '/' + projectname + '/'
  20. } else {
  21. var items = glob.sync("./src/views/*/*.js");
  22. for (var i in items) {
  23. var filepath = items[i];
  24. var fileList = filepath.split("/");
  25. var fileName = fileList[fileList.length - 2];
  26. publicPath = '/' + fileName + '/'
  27. console.log(fileName, 'fileName')
  28. entries[fileName] = {
  29. entry: `src/views/${fileName}/main.js`,
  30. // 模板来源
  31. template: `publ
  32. ic/index.html`,
  33. title: fileName == 'zhulao' ? '邹平养老' : '邹平未保客户端',
  34. // 在 dist/index.html 的输出
  35. filename: `${fileName}.html`,
  36. };
  37. }
  38. }
  39. return entries;
  40. }
  41. const path = require('path')
  42. function resolve(dir) {
  43. return path.join(__dirname, dir)
  44. }
  45. const port = process.env.port || process.env.npm_config_port || 12004 // dev port
  46. // const name = defaultSettings.title || 'vue Admin Template' // page title
  47. var pages = getEntry();
  48. console.log(publicPath)
  49. module.exports = {
  50. // publicPath:'/weibao/',
  51. // publicPath: publicPath,
  52. publicPath: process.env.NODE_ENV === 'development' ? publicPath : '././',
  53. productionSourceMap: false, // 生产禁止显示源代码
  54. outputDir: "dist/" + projectname,
  55. pages: pages,
  56. lintOnSave: process.env.NODE_ENV === 'development',
  57. productionSourceMap: false,
  58. devServer: {
  59. port: port,
  60. open: true,
  61. https: false,
  62. overlay: {
  63. warnings: false,
  64. errors: true
  65. },
  66. proxy: {
  67. [process.env.VUE_APP_BASE_API]: {
  68. target: 'https://test.poteviohealth.com/pmgw/',
  69. // target: 'http://localhost:12017/',
  70. changeOrigin: true,
  71. secure: false,
  72. pathRewrite: {
  73. ['^' + process.env.VUE_APP_BASE_API]: ''
  74. }
  75. },
  76. //
  77. [process.env.VUE_APP_ZL_WSS]: {
  78. target: 'https://cdbwss.poteviohealth.com/api/',
  79. // target: 'http://localhost:12017/',
  80. changeOrigin: true,
  81. secure: false,
  82. pathRewrite: {
  83. ['^' + process.env.VUE_APP_ZL_WSS]: ''
  84. }
  85. },
  86. [process.env.VUE_APP_ZL_WSS_ZP]: {
  87. target: 'https://web.poteviohealth.com/prod-api',
  88. // target: 'http://localhost:12017/',
  89. changeOrigin: true,
  90. secure: false,
  91. pathRewrite: {
  92. ['^' + process.env.VUE_APP_ZL_WSS_ZP]: ''
  93. }
  94. },
  95. [process.env.VUE_APP_ZL_WSS_ZP_BT]: {
  96. target: 'https://test.poteviohealth.com/subsidy',
  97. // target: 'http://localhost:12017/',
  98. changeOrigin: true,
  99. secure: false,
  100. pathRewrite: {
  101. ['^' + process.env.VUE_APP_ZL_WSS_ZP_BT]: ''
  102. }
  103. },
  104. [process.env.VUE_APP_ZL_JF]: {
  105. target: 'https://jifen.tjpoteviohealth.com/blade-api',
  106. // target: 'http://localhost:12017/',
  107. changeOrigin: true,
  108. secure: false,
  109. pathRewrite: {
  110. ['^' + process.env.VUE_APP_ZL_JF]: ''
  111. }
  112. },
  113. [process.env.VUE_APP_ZL_HEALTH]: {
  114. // https://web.poteviohealth.com/zhylsia/
  115. target: 'https://web.poteviohealth.com/zhylsia',
  116. // target: 'http://localhost:12017/',
  117. changeOrigin: true,
  118. secure: false,
  119. pathRewrite: {
  120. ['^' + process.env.VUE_APP_ZL_HEALTH]: ''
  121. }
  122. }
  123. }
  124. // after: require('./mock/mock-server.js')
  125. }
  126. };