Concat
1- Install the package and add it to the project dependencies
npm install gulp-concat --save-dev
2- Replace all of the JavaScript files you’re using in your project with one JavaScript file. Call it app.js
3- Add the gulp-concat
as a task
var concat = require('gulp-concat');
gulp.task("concat", function() {
gulp.src([
'js/jquer.js',
'js/sticky/jquer.sticky.js',
'js/main,js'])
.pipe(concat("app.js"))
.pip(gulp.dest("js"))
});
- Run the concat task
gulp concat
gulp.src([array_of_files])
Specify source files. This method can take a string or an array as it’s first parameter.
The order you provide files to gulp.src does not matter.pipe(concat("destination_file"))
Destination file name. Thepipe
method gets the readable stream of data to our next method.pip(gulp.dest("destination_folder"))
Destination foder. Gulp will overwrite files when the file stream is output usinggulp.dest
. Therefore, use the Rename package.
Uglify
JavaScript Minification with Uglify
npm install gulp-uglify --save-dev