简体   繁体   English

Gulp和Bower集成

[英]Gulp and Bower integration

I'm new to Gulp and Bower. 我是Gulp和Bower的新手。 I'd like to copy specific files from bower_components to a vendors folder in my app. 我想具体的文件从bower_componentsvendors文件夹在我的应用程序。 For instance, I'd like to only copy the angular.js file from bower_components/angular to app/vendors/libs . 例如, 我只想将angular.js文件从bower_components/angular复制到app/vendors/libs

I am not sure which Gulp plugins to use. 我不确定要使用哪个Gulp插件。 I see that there's gulp-bower , gulp-bower-files , and gulp-copy . 我看到有gulp-bowergulp-bower-filesgulp-copy I'm not sure which one to use, or if I should use all of them in the same task. 我不确定要使用哪个,或者我是否应该在同一任务中使用所有这些。

Is there an easy way to achieve this without specifying the src paths and dest paths for every single file I want to copy over? 有没有一种简单的方法可以实现此目的,而无需为我要复制的每个文件指定src路径和dest路径? I used to do that in Grunt and it was very tedious. 我曾经在Grunt中这样做,这很繁琐。 I am hoping Gulp will ease my pain (which it has done so far with other tasks). 我希望Gulp可以减轻我的痛苦(到目前为止,它已经完成了其他任务)。

gulp-bower-files should do what you want. gulp-bower-files应该做您想要的。 It will find the main files from your bower file. 它将从您的Bower文件中找到主文件。 You can then pipe these to a new destination. 然后,您可以将它们通过管道传送到新的目的地。

See the usage example at https://www.npmjs.com/package/gulp-bower-files 请参阅https://www.npmjs.com/package/gulp-bower-files中的用法示例

You would just need to change the destination for that to work as your task: 您只需要更改目标位置即可执行任务:

var gulpBowerFiles = require('gulp-bower-files');

gulp.task("bower-files", function(){
    gulpBowerFiles().pipe(gulp.dest("app/vendors/libs"));
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM