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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -