vue.config.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. entries[fileName] = {
  28. entry: `src/views/${fileName}/main.js`,
  29. // 模板来源
  30. template: `public/index.html`,
  31. // 在 dist/index.html 的输出
  32. filename: `${fileName}.html`,
  33. };
  34. }
  35. }
  36. return entries;
  37. }
  38. const path = require('path')
  39. function resolve(dir) {
  40. return path.join(__dirname, dir)
  41. }
  42. const port = process.env.port || process.env.npm_config_port || 12004 // dev port
  43. const name = 'vue Admin Template' // page title
  44. var pages = getEntry();
  45. console.log(process.env.VUE_APP_ZL_WSS, 'process.env.VUE_APP_ZL_WSS')
  46. console.log(process.env.VUE_APP_BASE_API, 'process.env.VUE_APP_ZL_WSS')
  47. module.exports = {
  48. // publicPath:'/weibao/',
  49. publicPath: publicPath,
  50. productionSourceMap: false, // 生产禁止显示源代码
  51. outputDir: "dist/" + projectname,
  52. pages: pages,
  53. lintOnSave: process.env.NODE_ENV === 'development',
  54. productionSourceMap: false,
  55. devServer: {
  56. port: port,
  57. open: true,
  58. https: false,
  59. overlay: {
  60. warnings: false,
  61. errors: true
  62. },
  63. proxy: {
  64. [process.env.VUE_APP_BASE_API]: {
  65. target: 'https://test.poteviohealth.com/pmgw/',
  66. // target: 'http://localhost:12017/',
  67. changeOrigin: true,
  68. secure: false,
  69. pathRewrite: {
  70. ['^' + process.env.VUE_APP_BASE_API]: ''
  71. }
  72. },
  73. //
  74. [process.env.VUE_APP_ZL_WSS]: {
  75. target: 'https://cdbwss.poteviohealth.com/api/',
  76. // target: 'http://localhost:12017/',
  77. changeOrigin: true,
  78. secure: false,
  79. pathRewrite: {
  80. ['^' + process.env.VUE_APP_ZL_WSS]: ''
  81. }
  82. },
  83. [process.env.VUE_APP_ZL_WSS_ZP]: {
  84. target: 'https://web.poteviohealth.com/prod-api',
  85. // target: 'http://localhost:12017/',
  86. changeOrigin: true,
  87. secure: false,
  88. pathRewrite: {
  89. ['^' + process.env.VUE_APP_ZL_WSS_ZP]: ''
  90. }
  91. },
  92. [process.env.VUE_APP_ZL_WSS_ZP_BT]: {
  93. target: 'https://test.poteviohealth.com/subsidy',
  94. // target: 'http://localhost:12017/',
  95. changeOrigin: true,
  96. secure: false,
  97. pathRewrite: {
  98. ['^' + process.env.VUE_APP_ZL_WSS_ZP_BT]: ''
  99. }
  100. },
  101. [process.env.VUE_APP_ZL_JF]: {
  102. target: 'https://jifen.tjpoteviohealth.com/blade-api',
  103. // target: 'http://localhost:12017/',
  104. changeOrigin: true,
  105. secure: false,
  106. pathRewrite: {
  107. ['^' + process.env.VUE_APP_ZL_JF]: ''
  108. }
  109. },
  110. [process.env.VUE_APP_ZL_HEALTH]: {
  111. target: 'http://web.poteviohealth.com:8080/',
  112. // target: 'http://localhost:12017/',
  113. changeOrigin: true,
  114. secure: false,
  115. pathRewrite: {
  116. ['^' + process.env.VUE_APP_ZL_HEALTH]: ''
  117. }
  118. }
  119. }
  120. // after: require('./mock/mock-server.js')
  121. },
  122. configureWebpack: {
  123. // provide the app's title in webpack's name field, so that
  124. // it can be accessed in index.html to inject the correct title.
  125. name: name,
  126. resolve: {
  127. alias: {
  128. '@': resolve('src')
  129. }
  130. }
  131. },
  132. };