pablocattaneo
11/27/2015 - 8:54 PM

Reference gulpfile.js Proyecto pablocattaneo

Reference gulpfile.js Proyecto pablocattaneo

//required section

var gulp = require('gulp'),
		uglify = require('gulp-uglify'),
		browserSync = require('browser-sync'),
		reload = browserSync.reload,
		minifyCss = require('gulp-minify-css'),
		sass = require('gulp-sass'),
		rename = require('gulp-rename');

// Scripts Task

gulp.task('scripts', function(){
	gulp.src(['wp-content/themes/pablo_cattaneo/js/*.js', '!wp-content/themes/pablo_cattaneo/js/*min.js']) // add the source that I want process (the first sting ) and exlude what I want to avoid (the secon string) 
	.pipe(rename({suffix:'.min'})) // remane processed file with the min suffix
	.pipe(uglify()) // run js minifier
	.pipe(gulp.dest('wp-content/themes/pablo_cattaneo/js/')); // set the output for the processed files
})

// Sass Task

gulp.task('sass', function(){
	gulp.src('wp-content/themes/pablo_cattaneo/style.sass') // add the source that I want process (the first sting ) and exlude what I want to avoid (the secon string) 
	.pipe(sass()) // run sass processer
	.pipe(gulp.dest('wp-content/themes/pablo_cattaneo/')) // set the output for the processed files
	.pipe(reload({stream:true}));
})

// Css Task

gulp.task('minifyCss', function(){
	gulp.src('wp-content/themes/pablo_cattaneo/style.css') // add the source that I want process (the first sting ) and exlude what I want to avoid (the secon string)
	.pipe(rename({suffix:'.min'})) // remane processed file with the min suffix
	.pipe(minifyCss()) // run nminify processer
	.pipe(gulp.dest('wp-content/themes/pablo_cattaneo/')); // set the output for the processed files	
})

// HTML tasks

gulp.task('html', function(){
	gulp.src('wp-content/themes/pablo_cattaneo/**/*.*')
});

// Browser-sync

gulp.task('browserSync', function(){
	browserSync({
			proxy: "localhost/pablocattaneo/" // Use the proxy option because the project has a php server
	});
});

// Watch task

gulp.task('watch', function(){
	gulp.watch('wp-content/themes/pablo_cattaneo/js/*.js', ['scripts']);
	gulp.watch('wp-content/themes/pablo_cattaneo/style.sass', ['sass']);
	gulp.watch('wp-content/themes/pablo_cattaneo/style.css', ['minifyCss']);
	gulp.watch('wp-content/themes/pablo_cattaneo/**/*.*', ['html']);
});

// Default Task
gulp.task('default', ['scripts','sass','minifyCss','html','browserSync','watch']);