Skip to content

Instantly share code, notes, and snippets.

@eristic
Last active April 1, 2017 13:07
Show Gist options
  • Save eristic/f57b4514f5d581e7e3a7ee18bd086ec9 to your computer and use it in GitHub Desktop.
Save eristic/f57b4514f5d581e7e3a7ee18bd086ec9 to your computer and use it in GitHub Desktop.
Gulp file for WordPress plugin development, based on Plugin Boilerplate: https://wppb.me/
// If you're interested in automating more control, check out gulpjs.com for more dependencies
// This is meant as a starting point. You can do a LOT more with gulpjs than this
// Put inside /public directory, saved as gulpfile.js
// Requiring dependencies here, make sure to add them via the terminal
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
minify = require('gulp-minify');
// Need to create a /sass folder inside the /css folder
gulp.task('build-that-css', function() {
return gulp.src('css/sass/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat('main.css'))
.pipe(gulp.dest('css/'));
});
gulp.task('compress-that-js', function() {
gulp.src('js/*.js')
.pipe(minify({
ext: {
src: 'main.js', // create main.js for all your JS
min: '.min.js'
}
}))
.pipe(gulp.dest('js/min/'))
// enqueue this minified file in your files, wherever you find appropriate
});
// Gulp is watching you and your coding with the command: gulp watch
gulp.task('watch', function() {
gulp.watch('css/sass/*.scss', ['build-that-css']);
gulp.watch('js/*.js', ['compress-that-js']);
});
gulp.task('default', ['watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment