git 配置 bower 只安装 dist 文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28619210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Configure bower to install only dist folder
提问by Neve12ende12
I am trying to learn tools such as bower/grunt/requirejs in order to speed up the development process for my website and to make my code more modularized/efficient. I am currently following this tutorial. How does one make Bower only install the dist folder for my dependencies (setup in my component.json file) instead of the entire Git repository?
我正在尝试学习诸如 bower/grunt/requirejs 之类的工具,以加快我网站的开发过程并使我的代码更加模块化/高效。我目前正在关注本教程。如何让 Bower 只为我的依赖项(在我的 component.json 文件中设置)而不是整个 Git 存储库安装 dist 文件夹?
采纳答案by nwinkler
What you're looking for is the ignoreproperty in bower.json
: https://github.com/bower/bower.json-spec
你正在寻找的是忽略属性bower.json
:https: //github.com/bower/bower.json-spec
The developer of the module can use the ignoreattribute to exclude files when the module is downloaded and installed through Bower.
当模块通过 Bower 下载和安装时,模块的开发者可以使用ignore属性来排除文件。
If you are the developer of said module, you can use the ignoreattribute to exclude everything but the distfolder.
如果您是上述模块的开发者,您可以使用ignore属性排除除dist文件夹之外的所有内容。
If you're not the developer of the module, then there's not much you can do, you will get whatever the developer of the module has deemed significant. In most cases, this is not a problem.
如果您不是模块的开发人员,那么您无能为力,您将获得模块开发人员认为重要的任何东西。在大多数情况下,这不是问题。
Here's a typical configuration for the ignoreattribute:
下面是ignore属性的典型配置:
{
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"package.json",
"src"
]
}
回答by Ariel
Bower does not provide any option to do that. Mostly because they have refused to.
Bower 没有提供任何选项来做到这一点。主要是因为他们拒绝了。
All we are left to is hacky ways to deal with it, like grunt-wiredep, which doesn't solve the problem in a strict sense.
我们剩下的就是处理它的hacky方法,比如grunt-wiredep,它不能解决严格意义上的问题。
Good luck!
祝你好运!
回答by Ben
From Bower's api documentation, there doesn't seem to be anything to say "Install just the dist folder".
从 Bower 的api 文档中,似乎没有什么可以说“只安装 dist 文件夹”。
As you are using Grunt already, you could probably create a task to run after your bower install
using grunt-contrib-cleanto remove unwanted files and folders from the bower_components
folder.
由于您已经在使用 Grunt,因此您可能会在bower install
使用grunt-contrib-clean从文件夹中删除不需要的文件和文件夹后,创建一个要运行的任务bower_components
。
Something like this should remove everything from the bower_components
folder except dist
folders:
像这样的东西应该从bower_components
文件dist
夹中删除除文件夹之外的所有内容:
clean : {
dist : ['bower_components/*/*', '!bower_components/*/dist']
}
While looking into this I also found grunt-bower-taskwhich seems to do exactly that. The only drawback I see to this method is that you have to create the bower.json by hand first and then run the grunt task.
在研究这个时,我还发现grunt-bower-task似乎正是这样做的。我看到这种方法的唯一缺点是您必须首先手动创建 bower.json,然后运行 grunt 任务。
回答by mummybot
This doesn't answer your question directly, but may help with what you are trying to accomplish.
这不会直接回答您的问题,但可能有助于您尝试完成的任务。
There are two plugins: grunt-wiredepand grunt-wiredep-copywhich can help you manage your bower dependencies. These automagically add the dependencies to your HTML, and can then grab the required minified ones and copy them to your dist folder.
有两个插件:grunt-wiredep和grunt-wiredep-copy,它们可以帮助您管理Bower依赖项。它们会自动将依赖项添加到您的 HTML,然后可以获取所需的缩小的依赖项并将它们复制到您的 dist 文件夹中。
I am however struggling with some aspects of this at How to manage bower dependencies when developing and deploying with grunt and a dist project folder?
然而,我在如何在使用 grunt 和 dist 项目文件夹进行开发和部署时管理凉亭依赖项中为此苦苦挣扎?