Nev*_*e12 25 javascript git bower
我正在尝试学习bower/grunt/requirejs等工具,以加快我网站的开发过程,并使我的代码更加模块化/高效.我目前正在学习本教程.如何让Bower只为我的依赖项(在我的component.json文件中设置)而不是整个Git存储库安装dist文件夹?
nwi*_*ler 22
您正在寻找的是:https://github.com/bower/bower.json-spec中的ignore属性bower.json
当通过Bower下载和安装模块时,模块的开发人员可以使用ignore属性来排除文件.
如果您是所述模块的开发人员,则可以使用ignore属性排除除dist文件夹之外的所有内容.
如果您不是该模块的开发人员,那么您无能为力,您将获得该模块的开发人员认为重要的任何内容.在大多数情况下,这不是问题.
这是ignore属性的典型配置:
{
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"package.json",
"src"
]
}
Run Code Online (Sandbox Code Playgroud)
从Bower的api文档中,似乎没有任何说法"只安装dist文件夹".
由于您已经在使用Grunt,因此在bower install使用grunt-contrib-clean从文件夹中删除不需要的文件和文件夹后,您可能会创建一个要运行的任务bower_components.
这样的东西应该删除bower_components文件夹以外的所有内容dist:
clean : {
dist : ['bower_components/*/*', '!bower_components/*/dist']
}
Run Code Online (Sandbox Code Playgroud)
在调查这一点的同时,我也发现了grunt-bower-task,它似乎正是这样做的.我看到这个方法的唯一缺点是你必须先手动创建bower.json然后运行grunt任务.