Skip to content

Instantly share code, notes, and snippets.

@matthewbeta
Last active December 20, 2015 23:49
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 matthewbeta/6215747 to your computer and use it in GitHub Desktop.
Save matthewbeta/6215747 to your computer and use it in GitHub Desktop.
Grunt file for Jekyll (with dev/staging builds) and Compass with ~~Live Reload~~ Grunt Style Injector. *Need to add (ghostMode)[https://github.com/shakyShane/grunt-style-injector#ghostmode-default-false-experimental] settings
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
// WATCH THE SASS FILES FOR CHNAGES AND COMPILE WITH COMPASS
compass: {
files: ['assets/sass/**/*.{scss,sass}' , 'assets/sass/**/*.{scss,sass}'],
tasks: ['copyCSS']
},
//WATCH ALL THE JEKYLL FILES EXCEPT CSS
jekyll: {
files: [
// capture all except css
'**/*.html', '*.yml', 'js/**.js', '!**/css/**'
],
tasks: ['jekyll:dev' , 'styleinjector']
}
},
jekyll: {
dev: {
drafts: true,
future: true
},
staging: {
config: "_config_staging.yml",
dest: "./_staging"
}
},
compass: {
dev: {
options: {
sassDir: ['assets/sass'],
cssDir: ['assets/css'],
environment: 'development'
}
},
prod: {
options: {
sassDir: ['assets/sass'],
cssDir: ['_staging/assets/css'],
environment: 'production'
}
}
},
connect: {
server: {
options: {
base: '_site/',
port: 9009
}
}
},
open: {
server: {
path: 'http://localhost:<%= connect.server.options.port %>/'
}
},
copy: {
css : {
files: [
{
src: 'assets/css/standards.css',
dest: '_site/assets/css/standards.css'
},
{
src: 'assets/css/style-guide.css',
dest: '_site/assets/css/style-guide.css'
}
]
}
},
styleinjector: {
files: {
src: [
'_site/assets/css/**/*.css' ,
'_site/assets/css/**/*.css',
'_site/**/*.html'
]
},
options: {
watchTask: true,
urlTransforms: {
remove : "_site",
},
},
},
});
// INCLUDE ALL THE GRUNT TASKS
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-style-injector');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-jekyll');
// COPY STYLES TO _SITE
grunt.registerTask('copyCSS', ['compass', 'copy:css', 'styleinjector']);
// RUN JEKYLL USING STAGING SETTINGS
grunt.registerTask('staging', ['compass:prod', 'jekyll:staging']);
// Default task.
grunt.registerTask('default', [
'jekyll:dev',
'copyCSS',
'connect:server',
'open:server',
'watch'
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment