vue.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. var pages = getEntry();
  36. module.exports = {
  37. productionSourceMap: false, // 生产禁止显示源代码
  38. outputDir: "dist/" + projectname,
  39. pages: pages
  40. };