由於懶,因此要提升開發效率,由於懶,因此要安裝第三方依賴javascript
yarn add glob -D //安裝依賴
const getEntries =(pathUrl)=>{ let pages={} glob.sync(pathUrl).map(filePath=>{ const fileName=filePath.substring(filePath.lastIndexOf("/")+1,filePath.lastIndexOf(".")) pages[fileName]={ /* 返回對應的入口頁面配置,詳情見vue-cli官網 */ template: `${filePath.substring(0, filePath.lastIndexOf("."))}.html`, entry:filePath, filename: fileName+".html", chunks: ['manifest', 'chunk-vendors','chunk-common',fileName], title:fileName } }) console.log(pages) return pages } const entries = getEntries("src/entries/**/*.js") //入口文件夾位置 module.exports={ pages:entries,//配置多入口 }