amitabhaghosh197
5/17/2017 - 5:12 AM

Important Gulp Files

Important Gulp Files

var gulp = require('gulp');
var gutil = require('gulp-util');

var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var merge = require('merge-stream');
var cleanCSS = require('gulp-clean-css');
var cssmin = require('gulp-cssmin');
var strip = require('gulp-strip-comments');
var urlAdjuster = require('gulp-css-url-adjuster');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');


var plumber = require('gulp-plumber');
var notify = require("gulp-notify");
var svgmin = require('gulp-svgmin');
var inlineFonts = require('gulp-inline-fonts');
var watch = require('gulp-watch');


//****************************//
 // SASS & CSS BUNDLE //
//****************************//


gulp.task('css-bundle', function(){

 

  var sassStream = gulp.src('../landing-html/assets/scss/main.scss')
                   .pipe(sourcemaps.init())
                   .pipe(sass().on("error", notify.onError({
                      message: "Error: <%= error.message %>",
                      title: "Error running something"
                    })))
                   
                   .pipe(plumber())
                   .pipe(notify("Found file: <%= file.relative %>!"))
                   .pipe(sourcemaps.write())
                   .pipe(gulp.dest('../landing-html/assets/css/'))
                   ;

  var cssStream  = gulp.src([
                              '../landing-html/assets/plugins/animateCSS/animate.min.css',
                              '../landing-html/assets/plugins/objectFit/polyfill.object-fit.css',
                              '../landing-html/assets/plugins/responsiveSlides/responsiveslides.css',
                              '../landing-html/assets/plugins/slickSlideer/slick.css',
                              '../landing-html/assets/plugins/slickSlideer/slick-theme.css',
                              '../landing-html/assets/css/main.css',
                              ])
                    
                    ;

var mergedStream = merge( sassStream, cssStream)
// Always pipe here otherwise will not work

                    .pipe(concat('apps.css'))
                    .pipe(gulp.dest('../landing-html/assets/css'))
                    .pipe(cleanCSS({compatibility: 'ie8'}))
                    .pipe(urlAdjuster({
                            prepend: '../img/',
                    
                             }))
                   .pipe(cssmin())

                    .pipe(rename({suffix:'.min'}))
                    .pipe(plumber())
                   .pipe(notify("Found file: <%= file.relative %>!"))
                    .pipe(gulp.dest('../landing-html/assets/css'));
return mergedStream;



});// css-bundle


//****************************//
 // CLEANSVG //
//****************************//

gulp.task('cleansvg', function () {
    return gulp.src('../landing-html/assets/svg_uncleaned/*.svg')
        .pipe(svgmin())
        .pipe(gulp.dest('../landing-html/assets/img/svg'));
});




//****************************//
 // WATCH //
//****************************//

gulp.task('watch', function() {

return gulp.watch(['../landing-html/assets/scss/*.scss', '../landing-html/assets/scss/**/*.scss'], [ 'css-bundle']);
return gulp.watch(['../landing-html/assets/css/*.css', '../landing-html/assets/css/**/*.css'], [ 'css-bundle']);
return gulp.watch(['../landing-html/assets/svg_uncleaned/*.svg'], [ 'cleansvg']);


});

gulp.task('default', ['css-bundle','cleansvg','watch']);