javascript - Concatenating files with Gulp -


im new using gulp. i'm trying concatenate javascript files single file. currently, have following:

gulpfile.js

var gulp = require('gulp'); var concat = require('gulp-concat'); var uglify = require('gulp-uglify');  var input = {     js: './src/**/*.js' };  var output = {     js: './dist/myjavascript.min.js' }  gulp.task('default', ['clean', 'bundle-js']);  gulp.task('clean', function(callback) {  });  gulp.task('bundle-js', function() {     gulp.src(input.js)         .pipe(concat(output.js))         .pipe(uglify())     ; }); 

when run this, myjavascript.min.js never gets generated. ran gulp --verbose , not see files being input. however, directory structure looks this:

/   /src     /childdirectory       file2.js     file1.js   gulpfile.js   package.json 

based on understanding, expression used input.js should file1.js , file2.js. doing wrong?

you should give

  1. file name inside concat function, should not give path name

  2. add return before including source.

  3. add destination

try following code,

gulp.task('bundle-js', function() {     return gulp.src(input.js)         .pipe(concat('myjavascript.min.js'))         .pipe(uglify())         .pipe(gulp.dest('./dist/'));      }); 

Comments