I have a grunt file as shown below. The problem I am having is when I change the contents of a .scss file, grunt watch sass does not trigger a refresh. Is there something obvious that I am doing wrong?
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
build : {
dest: '_site'
},
sass: {
dist: {
options: {
style: 'compressed',
trace: true
},
files: {
'css/main.css': '_scss/main.scss',
'css/ie8.css': '_scss/ie8.scss',
'css/ie9.css': '_scss/ie9.scss'
}
}
},
shell: {
jekyllBuild: {
command: 'jekyll build'
},
jekyllServe: {
command: 'jekyll serve'
}
},
watch: {
files: ['_layouts/*.html', '*.md', '*.yml'],
// SASS watch does not work :(
sass: {
files: ['_scss/**/*.scss'],
tasks: ['sass:dist'] // This should be sass'
}
}
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-jekyll');
// Compiles SASS, Builds Jekyll, and Serves Jekyll.
grunt.registerTask('default', ['sass:dist', 'shell:jekyllBuild', 'shell:jekyllServe']);
}
Also when I change a .scss file, the terminal indicates that a file has been changed but grunt watch sass does not run.
Regenerating: 1 file(s) changed at 2015-08-05 13:14:50 ...done in 0.017384 seconds.
EDIT:
I figured it out. What I was attempting to do was use grunt to watch my sass files and re-compile when changes were made. I also wanted jekyll to serve & watch the html files for changes. These things cannot be ran concurrently which was what I was attempting to do. I did happen to find a helper called 'load-grunt-tasks' which allows for concurrent tasks to be ran by adding the following code to the gruntfile:
concurrent: {
serve: [
'sass',
'watch',
'shell:jekyllServe'
],
options: {
logConcurrentOutput: true
}
},
// Then register the following tasks
// Register the grunt serve task
grunt.registerTask('serve', ['concurrent:serve']);
// Then run the following from the terminal:
grunt serve