Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattbanks
Last active June 13, 2019 12:09
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mattbanks/5143298 to your computer and use it in GitHub Desktop.
Save mattbanks/5143298 to your computer and use it in GitHub Desktop.
Gruntfile.js for use in developing and deploying WordPress themes
'use strict';
module.exports = function(grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
// watch for changes and trigger compass, jshint, uglify and livereload
watch: {
options: {
livereload: true,
},
compass: {
files: ['assets/scss/**/*.{scss,sass}'],
tasks: ['compass']
},
js: {
files: '<%= jshint.all %>',
tasks: ['jshint', 'uglify']
},
livereload: {
files: ['*.html', '*.php', 'assets/images/**/*.{png,jpg,jpeg,gif,webp,svg}']
}
},
// compass and scss
compass: {
dist: {
options: {
config: 'config.rb',
force: true
}
}
},
// javascript linting with jshint
jshint: {
options: {
jshintrc: '.jshintrc',
"force": true
},
all: [
'Gruntfile.js',
'assets/js/source/**/*.js'
]
},
// uglify to concat, minify, and make source maps
uglify: {
dist: {
options: {
sourceMap: 'assets/js/map/source-map.js'
},
files: {
'assets/js/plugins.min.js': [
'assets/js/source/plugins.js',
'assets/js/vendor/**/*.js',
'!assets/js/vendor/modernizr*.js'
],
'assets/js/main.min.js': [
'assets/js/source/main.js'
]
}
}
},
// image optimization
imagemin: {
dist: {
options: {
optimizationLevel: 7,
progressive: true
},
files: [{
expand: true,
cwd: 'assets/images/',
src: '**/*',
dest: 'assets/images/'
}]
}
},
// deploy via rsync
deploy: {
staging: {
src: "./",
dest: "~/path/to/theme",
host: "user@host.com",
recursive: true,
syncDest: true,
exclude: ['.git*', 'node_modules', '.sass-cache', 'Gruntfile.js', 'package.json', '.DS_Store', 'README.md', 'config.rb', '.jshintrc']
},
production: {
src: "./",
dest: "~/path/to/theme",
host: "user@host.com",
recursive: true,
syncDest: true,
exclude: '<%= rsync.staging.exclude %>'
}
}
});
// rename tasks
grunt.renameTask('rsync', 'deploy');
// register task
grunt.registerTask('default', ['watch']);
};
@hswolff
Copy link

hswolff commented Mar 15, 2013

What is this beautiful magic. I didn't even know there was a grunt-rsync plugin. Amazing, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment