Skip to content

Instantly share code, notes, and snippets.

@netsensei
Created December 15, 2013 14:34
Show Gist options
  • Save netsensei/7973699 to your computer and use it in GitHub Desktop.
Save netsensei/7973699 to your computer and use it in GitHub Desktop.
Grunt + Jekyll + Compass. Acts as a double pipeline: one line acts on HTML file changes, rebuilding the entire project, the second pipeline just acts on SCSS changes: watch, compile & copy to the jekyll compiled css folder. Includes livereload support via nodejs! Based on https://github.com/thanpolas/thanpolas.github.com/blob/master/Gruntfile.js
module.exports = function (grunt) {
"use strict";
// Config...
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
css : {
src: 'css/**',
dest: 'www/'
}
},
shell: {
jekyll: {
command: 'rm -rf www/*; jekyll build',
stdout: true
}
},
watch: {
options: {
livereload: true
},
html: {
files: ['**/*.html', '!_www/**/*.html'],
tasks: ['shell:jekyll']
},
css: {
files: ['./_sass/**/*.scss'],
tasks: ['compassCopy']
}
},
compass: {
dev: {
options: {
config: './config.rb',
sassDir: './_sass',
cssDir: './css',
environment: 'development'
}
},
prod: {
options: {
config: './config.rb',
sassDir: './sass',
cssDir: './css',
environment: 'production',
force: true
}
}
},
connect: {
server: {
options: {
livereload: true,
base: 'www/',
port: 9009,
}
}
},
});
// Load tasks...
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-shell');
// Define a compass compile & copy task for livereload
grunt.registerTask('compassCopy', ['compass:dev', 'copy:css']);
grunt.registerTask('prod', ['compass:prod']);
grunt.registerTask('server', [
'connect:server',
'watch'
]);
// Default task.
grunt.registerTask('default', 'server');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment