1

Im new to using Gulp. I'm trying to concatenate my JavaScript files into a single file. Currently, I have the 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 I run this, myJavaScript.min.js never gets generated. I ran gulp --verbose and I do not see any files being input. However, my directory structure looks like this:

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

Based on my understanding, the expression I used for input.js should get file1.js and file2.js. What am I doing wrong?

2 Answers 2

1

You should give

  1. file name inside concat function, you should not give it as a path name

  2. add return before including source.

  3. add destination

try the following code,

gulp.task('bundle-js', function() { return gulp.src(input.js) .pipe(concat('myJavaScript.min.js')) .pipe(uglify()) .pipe(gulp.dest('./dist/')); }); 
Sign up to request clarification or add additional context in comments.

Comments

0

You are missing your destination folder.

gulp-concat-link

.pipe(gulp.dest('folderPathHere')); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.