Last active
August 29, 2015 14:23
-
-
Save curiouscrusher/b71a12e2ce8b1b9d2b16 to your computer and use it in GitHub Desktop.
A simple Gulpfile for use with the _S Wordpress starter theme. Still working out a few naming conventions.
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
// Load dependencies | |
var gulp = require('gulp' ), | |
sass = require('gulp-ruby-sass'), | |
autoprefixer = require('gulp-autoprefixer'), | |
livereload = require('gulp-livereload'), | |
sourcemaps = require('gulp-sourcemaps'); | |
// Config variables | |
var config = new (function(){ | |
this.package = 'wp-content/themes/your-theme-name/', | |
this.sass_dir = this.package + 'scss', | |
this.css_dir = this.package, | |
this.js_dir = this.package + 'js'; | |
})(); | |
// Register tasks | |
gulp.task('styles', function() { | |
return sass(config.sass_dir, | |
{ | |
sourcemap: true, | |
style: 'expanded' | |
}) | |
.on('error', function (err) { | |
console.error('Error!', err.message); | |
}) | |
.pipe(autoprefixer({ | |
browsers: ['last 2 version', 'ios 6', 'android 4'], | |
cascade: false | |
})) | |
.on('error', function (err) { | |
console.error('Error', err.message); | |
}) | |
.pipe(sourcemaps.write('./', { | |
includeContent: false, | |
sourceRoot: config.sass_dir | |
})) | |
.pipe(gulp.dest(config.css_dir)); | |
}); | |
gulp.task('watch', function() { | |
// Create a LiveReload server | |
var lr = livereload; | |
lr.listen(); | |
// Compile SCSS | |
gulp.watch(config.sass_dir + '/*.scss', ['styles']); | |
// Subfolder files | |
gulp.watch(config.sass_dir + '/*/*.scss', ['styles']); | |
// Live Reload | |
gulp.watch(config.css_dir + '/style.css', lr.changed); | |
gulp.watch(config.js_dir + '/*.js', lr.changed); | |
}); | |
gulp.task('default', ['styles', 'watch']); |
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
{ | |
"name": "ProjectName", | |
"version": "1.0.0", | |
"description": "YourProjectDescription", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "YourRepoUrl" | |
}, | |
"author": "YourName", | |
"devDependencies": { | |
"gulp": "^3.9.0", | |
"gulp-autoprefixer": "^2.3.0", | |
"gulp-livereload": "^3.8.0", | |
"gulp-ruby-sass": "^1.0.5", | |
"gulp-sourcemaps": "^1.5.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment