gulp-sourcemaps npm package of node.js


Overview

Source are basically used along with some other plugin. for example when you use gulp-clean-css the minified css file is created but with the help of source maps we can also reach the original file with a url which was embedded in the min file.

Code


													
var gulp = require('gulp');
var cleanCss = require('gulp-clean-css');
var sourcemaps = require('gulp-sourcemaps');

// name of the task is :  source-maps 
gulp.task('source-maps', function() {		
    return gulp.src('source/*.css')			//add your custom source here
        .pipe(sourcemaps.init())
        .pipe(cleanCSS())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('maps'));			// name of the destination folder comes here
});	
        
													
												

Run

  • Now run the snippet using the following command :
    													
    $gulp source-maps