vue.config.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. var projectname = process.argv[3];
  2. var glob = require("glob");
  3. var publicPath = ''
  4. console.log(process.env.NODE_ENV)
  5. function getEntry() {
  6. var entries = {};
  7. if (process.env.NODE_ENV == "production") {
  8. entries = {
  9. index: {
  10. // page的入口
  11. entry: "src/views/" + projectname + "/main.js",
  12. // 模板来源
  13. template: "public/index.html",
  14. // 在 dist/index.html 的输出
  15. filename: "index.html",
  16. title: projectname == 'weibao' ? '未成年人保护' : '助老',
  17. chunks: ["chunk-vendors", "chunk-common", "index"]
  18. }
  19. };
  20. publicPath = '/' + projectname + '/'
  21. } else {
  22. var items = glob.sync("./src/views/*/*.js");
  23. for (var i in items) {
  24. var filepath = items[i];
  25. var fileList = filepath.split("/");
  26. var fileName = fileList[fileList.length - 2];
  27. publicPath = '/' + fileName + '/'
  28. entries[fileName] = {
  29. entry: `src/views/${fileName}/main.js`,
  30. // 模板来源
  31. template: `public/index.html`,
  32. // 在 dist/index.html 的输出
  33. filename: `${fileName}.html`,
  34. };
  35. }
  36. }
  37. return entries;
  38. }
  39. const path = require('path')
  40. function resolve(dir) {
  41. return path.join(__dirname, dir)
  42. }
  43. const port = process.env.port || process.env.npm_config_port || 12004 // dev port
  44. const name = 'vue Admin Template' // page title
  45. var pages = getEntry();
  46. console.log(publicPath)
  47. module.exports = {
  48. // publicPath:'/weibao/',
  49. // publicPath: publicPath,
  50. publicPath: process.env.NODE_ENV === 'development' ? publicPath : '././',
  51. productionSourceMap: false, // 生产禁止显示源代码
  52. outputDir: "dist/" + projectname,
  53. pages: pages,
  54. lintOnSave: process.env.NODE_ENV === 'development',
  55. productionSourceMap: false,
  56. devServer: {
  57. host: '127.0.0.1',
  58. port: port,
  59. open: true,
  60. https: false,
  61. overlay: {
  62. warnings: false,
  63. errors: true
  64. },
  65. proxy: {
  66. [process.env.VUE_APP_BASE_API]: {
  67. target: 'https://web.poteviohealth.com/pmgw/',
  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. configureWebpack: {
  127. // provide the app's title in webpack's name field, so that
  128. // it can be accessed in index.html to inject the correct title.
  129. name: name,
  130. resolve: {
  131. alias: {
  132. '@': resolve('src')
  133. }
  134. }
  135. },
  136. };