I have an app written in Coffeescript. My grunt.js file looks like this:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
test: {
files: [{
src: ['.tmp']
}]
}
},
coffee: {
compileScripts: {
expand: true,
flatten: true,
src: '*/*.coffee',
dest: '.tmp/scripts',
ext: '.js'
},
},
jst: {
compile: {
files: {
'.tmp/scripts/templates.js': ['scripts/**/*.ejs']
}
}
},
watch: {
all: {
options: {
livereload: true,
spawn: false
},
files: ['scripts/*.coffee', 'scripts/*.ejs', 'index.html'],
tasks: ['compile'],
}
},
connect: {
server: {
options: {
port: 8000,
hostname: 'localhost',
open: true,
livereload: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-jst');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('compile', ['clean', 'coffee', 'jst']);
grunt.registerTask('default', ['compile', 'connect', 'watch']);
}
After much tinkering, I finally got the 'watch' working where my JS files are live reloading, but I'm not clear on what goes in the 'files' section of the watch task? Did I do it right?
Do I have to watch the coffeescript files only? Or do I also have to watch index.html so that if one of the coffeescript files change, the index.html will refresh and reload the new JS? (All of my JS files are scripts in my index.html.)