Bower解决了前端依赖的获取问题,而Wiredep的初衷是为了解决前端依赖的自动引用问题。
比如来个简单的例子,以Bootstrap为例,在html中添加
<html> <head> <!-- bower:css --> <!-- endbower --> </head> <body> <!-- bower:js --> <!-- endbower --> </body> </html>
那么在安装bootstrap以后我们会发现只有bootstrap.js被正常引用了,但是对应的css并没有。
这是因为wiredep的工作原理是检查依赖的bower.json文件,并根据其中的main和dependencies来判断需要注入的文件和对应的依赖。而Bootstrap的bower.json文件如下:
{
"name": "bootstrap",
"description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
…

…