Skip to content

Instantly share code, notes, and snippets.

@Emerson
Last active October 20, 2020 13:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Emerson/a1f62586a39c9f1a2484 to your computer and use it in GitHub Desktop.
Save Emerson/a1f62586a39c9f1a2484 to your computer and use it in GitHub Desktop.
Example Gulpfile used on a legacy WordPress project
{
"directory": "vendor"
}
{
"name": "TEDxTheme",
"version": "1.0.0",
"homepage": "https://github.com/twg/TEDxTheme",
"authors": [
"Emerson Lackey & Bil Li"
],
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"vendor",
"test",
"tests"
],
"dependencies": {
"bootstrap": "~3.1.1"
}
}
var gulp = require('gulp'),
sass = require('gulp-sass'),
livereload = require('gulp-livereload'),
tinylr = require('tiny-lr'),
autoprefixer = require('gulp-autoprefixer'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
clean = require('gulp-clean'),
concat = require('gulp-concat');
//-- Bower Dependencies -----------------------------------------------------
var bowerJsDependencies = [
'./vendor/jquery/dist/jquery.js',
'./vendor/bootstrap/dist/js/bootstrap.js'
];
var bowerCssDependencies = [
'./vendor/bootstrap/dist/css/bootstrap.css'
];
//-- Compile SCSS -----------------------------------------------------------
gulp.task('styles', function() {
return gulp.src('./assets/scss/*.scss')
.pipe(sass({style: 'expand'}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('./dist/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('./dist/css'));
});
//-- Compile Javascripts ----------------------------------------------------
gulp.task('scripts', function() {
return gulp.src('./assets/js/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('application.js'))
.pipe(gulp.dest('dist/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist/js/'));
});
//-- Merge and Minify Bower JS Dependencies ------------------------------------
gulp.task('vendor-js', function() {
return gulp.src(bowerJsDependencies)
.pipe(concat('vendor.js'))
.pipe(gulp.dest('./dist/js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
});
//-- Merge and Minify Bower CSS Dependencies --------------------------------
gulp.task('vendor-css', function() {
return gulp.src(bowerCssDependencies)
.pipe(concat('vendor.css'))
.pipe(gulp.dest('./dist/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('dist/css'));
});
//-- Clean task to run before deploys ---------------------------------------
gulp.task('clean', function() {
return gulp.src(['./dist/assets/css', './dist/assets/js'], {read: false})
.pipe(clean());
});
//-- Default Task -----------------------------------------------------------
gulp.task('default', function() {
gulp.start('styles', 'scripts', 'vendor-css', 'vendor-js');
});
//-- Watching & Livereload --------------------------------------------------
gulp.task('watch', function() {
gulp.watch('./assets/scss/**/*.scss', ['styles']);
gulp.watch('./assets/js/**/*.js', ['scripts']);
livereload.listen();
gulp.watch(['./dist/**', './**/*.php']).on('change', livereload.changed);
});
{
"name": "TEDxTheme",
"version": "1.0.0",
"description": "A TEDx WordPress theme built by The Working Group (http://twg.ca) and TEDxToronto.",
"main": "Gulpfile.js",
"dependencies": {
"gulp": "^3.7.0"
},
"devDependencies": {
"gulp": "^3.7.0",
"gulp-concat": "^2.2.0",
"gulp-uglify": "^0.3.0",
"gulp-livereload": "^2.0.0",
"gulp-sass": "^0.7.2",
"gulp-autoprefixer": "0.0.7",
"gulp-notify": "^1.3.1",
"gulp-clean": "^0.3.0",
"gulp-minify-css": "^0.3.4",
"gulp-jshint": "^1.6.2",
"gulp-cache": "^0.1.11",
"gulp-rename": "^1.2.0",
"tiny-lr": "0.0.7"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/twg/TEDxTheme.git"
},
"author": "Emerson Lackey & Bill Li",
"license": "MIT",
"bugs": {
"url": "https://github.com/twg/TEDxTheme/issues"
},
"homepage": "https://github.com/twg/TEDxTheme"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment