Array-Huang / webpack-seed

这是一个基于webpack的多页应用脚手架
https://segmentfault.com/a/1190000006843916
MIT License
1.19k stars 283 forks source link

文件路径输出带文件后缀 #59

Closed DonaldY closed 6 years ago

DonaldY commented 6 years ago

输出就会类似: index/index.js/entry.dfd0c1009249ba48d59e.js

在entry.config.js 中 进行截取 page = page.substring(0, page.lastIndexOf('.'));

pageArr.forEach((page) => {
    page = page.substring(0, page.lastIndexOf('.'));
    configEntry[page] = path.resolve(dirVars.pagesDir, page);
});

============ 2补。 大大可能让每个文件都是有个entry 比如 index/index.css : index/index.css 但貌似只能js作为入口,so,为了只让js过滤,

function isJsFile(str)  {  
   var objRegExp = /\.js/;
   return objRegExp.test(str);  
}  

pageArr.forEach((page) => {
    if (isJsFile(page)) {
    page = page.substring(0, page.lastIndexOf('.'));
    configEntry[page] = path.resolve(dirVars.pagesDir, page);
    }
});

有理解错误的话,望见谅,望能指出。