I would like to minified the .js files of the bower packages in my project. Usually, gulp will read the source files and the pipe them into new files but this time i would like to overwrite the original file without creating a .min.js file.
Example:
gulp.task('jsmin', function() { return gulp.src('bower_components/**/*.js', {base: './'}) .pipe(sourcemaps.init()) .pipe(uglify()) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('./')); });
The above task will read those .js files inside the bower_components folder, uglify the source file and create the corresponding .map file for each .js file in the same folder.
Done =)
Reference: StackOverflow – Can Gulp overwrite all src files?
One thought on “Gulp – Rewrite source files instead of creating new files”