Reputation: 1983
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?
Upvotes: 1
Views: 265
Reputation: 3892
You should give
file name inside concat function, you should not give it as a path name
add return before including source.
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/'));
});
Upvotes: 1
Reputation: 15912
You are missing your destination folder.
.pipe(gulp.dest('folderPathHere'));
Upvotes: 0