javascript - How to use gulp install bower -


i want when run gulp:

1.use "gulp-bower" install dependency bower.json.

2.use "main-bower-files" find bower component , concat them 1 file

var gulp = require('gulp'); var bower = require('gulp-bower'); var mainbowerfiles = require('main-bower-files');  gulp.task('default', function () {     return bower()         .pipe(gulp.src(mainbowerfiles()))         .pipe(concat('lib.js'))         .pipe(gulp.dest('static/lib')); }); 

but give error: bower components directory not exist first, download bower components after. how can download components first run main-bower-files

gulp-bower runs asynchronously, moves along next part of pipe before files have finished downloading. solve this, you'll need separate tasks:

var gulp = require('gulp'); var bower = require('gulp-bower'); var concat = require('gulp-concat'); var mainbowerfiles = require('main-bower-files');  gulp.task('bower', function () {     return bower(); });  gulp.task('bower-concat', ['bower'], function () {     return gulp.src(mainbowerfiles())         .pipe(concat('lib.js'))         .pipe(gulp.dest('static/lib')); });  gulp.task('default', ['bower-concat']); 

Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -