vue.config.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. var projectname = process.argv[3];
  2. var glob = require("glob");
  3. function getEntry() {
  4. var entries = {};
  5. if (process.env.NODE_ENV == "production") {
  6. entries = {
  7. index: {
  8. // page的入口
  9. entry: "src/views/" + projectname + "/main.js",
  10. // 模板来源
  11. template: "public/index.html",
  12. // 在 dist/index.html 的输出
  13. filename: "index.html",
  14. title: projectname,
  15. chunks: ["chunk-vendors", "chunk-common", "index"]
  16. }
  17. };
  18. } else {
  19. var items = glob.sync("./src/views/*/*.js");
  20. for (var i in items) {
  21. var filepath = items[i];
  22. var fileList = filepath.split("/");
  23. var fileName = fileList[fileList.length - 2];
  24. entries[fileName] = {
  25. entry: `src/views/${fileName}/main.js`,
  26. // 模板来源
  27. template: `public/index.html`,
  28. // 在 dist/index.html 的输出
  29. filename: `${fileName}.html`,
  30. };
  31. }
  32. }
  33. return entries;
  34. }
  35. const path = require('path')
  36. function resolve(dir) {
  37. return path.join(__dirname, dir)
  38. }
  39. const port = process.env.port || process.env.npm_config_port || 12004 // dev port
  40. const name = 'vue Admin Template' // page title
  41. console.log('projectname===')
  42. console.log(process.argv)
  43. console.log(projectname)
  44. var pages = getEntry();
  45. module.exports = {
  46. productionSourceMap: false, // 生产禁止显示源代码
  47. outputDir: "dist/" + projectname,
  48. pages: pages,
  49. lintOnSave: process.env.NODE_ENV === 'development',
  50. productionSourceMap: false,
  51. devServer: {
  52. port: port,
  53. open: true,
  54. overlay: {
  55. warnings: false,
  56. errors: true
  57. },
  58. proxy: {
  59. [process.env.VUE_APP_BASE_API]: {
  60. target: 'https://test.poteviohealth.com/pmgw/',
  61. // target: 'http://localhost:12017/',
  62. changeOrigin: true,
  63. secure: false,
  64. pathRewrite: {
  65. ['^' + process.env.VUE_APP_BASE_API]: ''
  66. }
  67. }
  68. }
  69. // after: require('./mock/mock-server.js')
  70. },
  71. configureWebpack: {
  72. // provide the app's title in webpack's name field, so that
  73. // it can be accessed in index.html to inject the correct title.
  74. name: name,
  75. resolve: {
  76. alias: {
  77. '@': resolve('src')
  78. }
  79. }
  80. },
  81. };