Webpack uses resolve.extensions to generate all the possible paths to the module, e.g.
function getPaths(module) {
return ['', '.js', '.css'].map(ext => module + ext);
}
getPaths('./somefile'); // ['./somefile', './somefile.js', './somefile.css']
getPaths('./somefile.js'); // ['./somefile.js', './somefile.js.js', './somefile.js.css']
Webpack would then proceed to lookup each of those paths until it finds a file.
直接解釋就是凰慈,數(shù)組內(nèi)填入什么后綴呢诬,引入該后綴時(shí)可以文件名可以不帶后綴
這就可以解釋手動(dòng)書(shū)寫(xiě)resolve.extensions時(shí)為什么要必須要加入‘’氮兵,否則require全名時(shí)反而無(wú)法解析