Skip to content

Instantly share code, notes, and snippets.

@decthomas decthomas/Gruntfile.js
Last active Dec 15, 2015

What would you like to do?
Example Gruntfile.js for use with Jekyll
// This is the main application configuration file. It is a Grunt
// configuration file, which you can learn more about here:
/*jslint nomen: true*/
'use strict';
module.exports = function (grunt) {
'use strict';
// The clean task ensures the entire XXX folder is removed
clean: {
development: ['_site'],
staging: ['_staging'],
production: ['_production']
// Compress generated css files
cssmin: {
'css/screen.css': ['css/screen.css']
// Run Jekyll
jekyll: {
server: {
auto: true,
server: true,
server_port: 5000,
exclude: ['node_modules', 'less'],
dest: './_site'
staging: {
url: 'http://some.url/',
exclude: ['node_modules', 'less'],
dest: './_staging'
production: {
exclude: ['node_modules', 'less'],
dest: './_production'
// Automatically run a task when a file changes
watch: {
styles: {
files: [
tasks: 'less'
// Compile specified less files
less: {
compile: {
options: {
// These paths are searched when trying to resolve @import in less file
paths: [
files: {
'css/screen.css': 'css/less/screen.less'
// Add shell tasks
shell: {
copyCss: {
command: 'cp css/screen.css _site/css/screen.css'
// The default task will show the usage
grunt.registerTask('default', 'Prints usage', function () {
grunt.log.writeln('Product site development');
grunt.log.writeln('* run "grunt --help" to get an overview of all commands.');
grunt.log.writeln('* run "grunt dev"" to start developing.');
// The dev task will be used during development
grunt.registerTask('dev', ['clean:development', 'less:compile', 'jekyll:server', 'watch:jekyll', 'watch:styles']);
// The stag task will be used before "deploying" to staging (subfolder of a domain)
grunt.registerTask('stag', ['clean:staging', 'less:compile', 'jekyll:staging']);
// The prod task will be used before "deploying" to product (root of a domain)
grunt.registerTask('prod', ['clean:production', 'less:compile', 'jekyll:production']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.