Last active
August 29, 2015 14:00
-
-
Save stefthoen/25c7f0320a2084037ad4 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"); | |
var gulpLoadPlugins = require("gulp-load-plugins"); | |
var plugins = gulpLoadPlugins(); | |
var browserSync = require("browser-sync"); | |
// Set paths for tasks | |
var paths = { | |
scss: ['_/scss/*.scss', '_/scss/**/*.scss'], | |
js: ['_/js-src/*.js'], | |
svg: ['_/img-src/icons/*'], | |
php: ['*.php', 'includes/*.php', 'parts/**/*.php', 'woocommerce/*.php', 'woocommerce/**/*.php'] | |
}; | |
// Set sprite names for gulp-svg-sprites | |
var svg = plugins.svgSprites.svg; | |
var png = plugins.svgSprites.png; | |
gulp.task('scss', function() { | |
gulp.src(paths.scss) | |
.pipe(plugins.plumber({errorHandler: plugins.notify.onError("Error: <%= error.message %>")})) | |
.pipe(plugins.rubySass()) | |
.pipe(plugins.concat('style.css')) | |
.pipe(plugins.autoprefixer('last 2 versions', 'ie 9', 'ios 6', 'android 4')) | |
.pipe(gulp.dest('.')) | |
.pipe(browserSync.reload({ stream: true })) | |
.pipe(plugins.notify('SCSS task done')) | |
}); | |
gulp.task('scss-lint', function() { | |
gulp.src(paths.scss) | |
.pipe(plugins.scsslint()) | |
.pipe(plugins.scsslint.reporter()) | |
}); | |
gulp.task('js-lint', function() { | |
gulp.src(paths.js) | |
.pipe(plugins.jshint()) | |
.pipe(plugins.jshint.reporter('jshint-stylish')) | |
}); | |
gulp.task('uglify', function() { | |
gulp.src(paths.js) | |
.pipe(plugins.concat('paprikapatterns.min.js')) | |
// .pipe(plugins.uglify()) | |
.pipe(gulp.dest('_/js')) | |
.pipe(browserSync.reload({ stream: true, once: true })) | |
}); | |
gulp.task('sprites', function() { | |
gulp.src(paths.svg) | |
.pipe(svg()) | |
.pipe(gulp.dest("_/img")) | |
.pipe(png()) | |
}); | |
// Browser-sync task for starting the server | |
gulp.task('browser-sync', function() { | |
browserSync.init(null, { | |
proxy: "dev.paprikapatterns.com", | |
browser: "google chrome canary" | |
}); | |
}); | |
gulp.task('bs-reload', function () { | |
browserSync.reload(); | |
}); | |
// Rerun the task when a file changes | |
gulp.task('watch', function() { | |
gulp.watch(paths.scss, ['scss', 'scss-lint']); | |
gulp.watch(paths.js, ['js-lint', 'uglify']); | |
gulp.watch(paths.svg, ['sprites']); | |
gulp.watch(paths.php, ['bs-reload']); | |
}); | |
gulp.task('default', ['watch', 'scss', 'scss-lint', 'js-lint', 'uglify', 'sprites', 'browser-sync']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment