Last active
September 16, 2017 00:10
-
-
Save pablocattaneo/415923a0be35c5cd647d to your computer and use it in GitHub Desktop.
Reference gulpfile.js Proyecto pablocattaneo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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']); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment