Skip to content

Instantly share code, notes, and snippets.

@eldh
Created November 4, 2013 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eldh/7309365 to your computer and use it in GitHub Desktop.
Save eldh/7309365 to your computer and use it in GitHub Desktop.
Gruntfile for jekyll livereload with css/sass injection.
module.exports = function(grunt) {
// load all grunt tasks
pkg: grunt.file.readJSON('package.json'),
// Project configuration.
grunt.initConfig({
copy: {
dist: {
files: {
'_site_git/' : '_site/**'
}
},
css : {
files: {
'_site/assets/themes/eldh/css/blag.css': 'assets/themes/eldh/css/blag.css'
}
}
},
shell: {
jekyll: {
command: 'rm -rf _site/*; jekyll --no-auto',
options: {
stdout: false,
stderr: false,
failOnError: false
}
}
},
sass: {
dist: {
files: {
'assets/themes/eldh/css/blag.css' : 'assets/themes/eldh/css/blag.scss'
}
}
},
watch: {
livereload: {
files: ['_site/**/*.css', '_site/**/*.html', '**/*.md'],
options: {
livereload: true
}
},
css: {
files: ['*.css']
},
sass: {
files: 'assets/themes/eldh/css/**/*.scss',
tasks: ['sassCopy'],
options: {
spawn: true
}
},
jekyllSources: {
files: [
// capture all except css
'*.html', '*.yml', 'assets/themes/eldh/js/**.js', '_posts/**',
'projects/**', 'blog/**', 'about/**', '_includes/**',
'atom.xml', '**/*.md'
],
tasks: ['shell:jekyll']
}
},
connect: {
server: {
options: {
base: '_site/',
port: 1337
}
}
},
open: {
server: {
path: 'http://localhost:<%= connect.server.options.port %>/'
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-open');
grunt.registerTask('sassCopy', ['sass:dist', 'copy:css']);
grunt.registerTask('server', [
'connect:server',
'open: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