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.
直接解释就是,数组内填入什么后缀,引入该后缀时可以文件名可以不带后缀
这就可以解释手动书写resolve.extensions时为什么要必须要加入‘’,否则require全名时反而无法解析