Last active
September 19, 2015 19:48
-
-
Save cannap/25b71d73c254118a2e02 to your computer and use it in GitHub Desktop.
This file contains 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
var gulp = require('gulp'), | |
sass = require('gulp-sass'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
notify = require('gulp-notify'), | |
plumber = require('gulp-plumber'), | |
sourcemaps = require('gulp-sourcemaps'), | |
autoprefixer = require('gulp-autoprefixer'), | |
browserSync = require('browser-sync').create(), | |
rename = require('gulp-rename'), | |
reload = browserSync.reload, | |
sourcemaps = require('gulp-sourcemaps'), | |
csso = require('gulp-csso'), | |
autoprefixer = require('gulp-autoprefixer'), | |
uncss = require('gulp-uncss'); | |
/******************************************************* | |
* Main Task | |
*******************************************************/ | |
gulp.task('serve', ['sass'], function () { | |
browserSync.init({ | |
proxy: "wordpress.dev/wordpress" | |
}); | |
gulp.watch("./scss/**/*.scss", ['sass']); | |
gulp.watch("style.css", browserSync.reload); | |
gulp.watch(".assets/js/vendor/*.js", ['vendor-js']); | |
gulp.watch(["./**/*.*", "!style.css", "!./**/scss/**/*.scss", "!./assets/js/**/*.js"], browserSync.reload); | |
}); | |
gulp.task('reload', function () { | |
browserSync.reload; | |
}); | |
/** | |
* Autoprefixer | |
*/ | |
gulp.task('autoprefixer', function () { | |
return gulp.src('./style.css') | |
.pipe(autoprefixer({ | |
browsers: ['last 2 versions'], | |
cascade: false | |
})) | |
.pipe(gulp.dest('./test')); | |
}) | |
/******************************************************* | |
* Sass | |
*******************************************************/ | |
gulp.task('sass', function () { | |
var onError = function (err) { | |
notify.onError({ | |
title: "Gulp", | |
subtitle: "Failure!", | |
message: "Error: <%= error.message %>", | |
sound: "Beep" | |
})(err); | |
this.emit('end'); | |
}; | |
gulp.src('./scss/devstyle.scss', {sourcemap: true}) | |
.pipe(plumber({errorHandler: onError})) | |
.pipe(sourcemaps.init()) | |
.pipe(sass()) | |
.pipe(autoprefixer({ | |
browsers: ['last 2 versions'], | |
cascade: false | |
})) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest('./assets/style')) | |
}); | |
gulp.task('vendor-js', function () { | |
return gulp.src('./assets/js/vendor/*.js') | |
.pipe(concat('vendor.min.js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('./assets/js/')); | |
}); | |
/******************************************************* | |
* Todo: Productions minify concat the rest at the end | |
* UNCSS | |
*******************************************************/ | |
gulp.task('minifycss', function () { | |
return gulp.src('./assets/style/devstyle.css') | |
.pipe(uncss({ | |
media: [ | |
'(min-width: 320px) and (max-width: 767px)', | |
'(min-width: 768px) and (max-width: 991px)', | |
'(min-width: 992px) and (max-width: 1199px)', | |
], | |
//Todo: add every Custom Page or Template site | |
html: [ | |
'http://wordpress.dev/wordpress/home', | |
'http://wordpress.dev/wordpress/works', | |
'http://wordpress.dev/wordpress/works/other-project/', | |
'http://wordpress.dev/wordpress/contact' | |
], | |
report: true, | |
//Todo: add every class or id used in JS | |
ignore: [ | |
/\.(open|tcon|inner-nav|animated)/ | |
], | |
})) | |
.pipe(csso()) | |
.pipe(rename('style.min.css')) | |
.pipe(gulp.dest('./assets/style/')); | |
}) | |
gulp.task('default', ['serve']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment