grunt-reload icon indicating copy to clipboard operation
grunt-reload copied to clipboard

trigger changes in js, scss and html separately

Open zigotica opened this issue 12 years ago • 3 comments

Hi,

Is there a way to trigger changes in js, scss and html separately? It would be useful to make a change in a Javascript file and make grunt lint and reload, whereas if I change a SCSS file I just want to convert to CSS and reload. That way reloads would perform faster.

Something like (following code will not work):

watchcss:{
  files:['sources/compass/*.scss'],
  tasks:'sass reload'
},
watchjs:{
  files:['sources/js/ours/*.js'],
  tasks:'lint concat min reload'
},
watchpage:{
  files:['index.html'],
  tasks:'reload'
}

// more stuff here

grunt.registerTask('default', 'server reload watchcss watchjs watchpage');

Thank you

zigotica avatar Oct 16 '12 21:10 zigotica

Yes, it can be done. This is extracted from a current gruntfile I am using:

watch: {
  less: {
    files: ['www-root/styles/**/*.less'],
    tasks: 'less'
  },
  coffee: {
    files: ['www-root/coffee/main.coffee'],
    tasks: 'coffee'
  },
  haml: {
    files: ['templates/**/*.hamlc'],
    tasks: 'shell:haml_local'
  },
  img: {
    files: ['<config:image.files>'],
    tasks: 'shell:copy_images'
  },
  reload: {
    files: ['<config:reload.files>','<config:image.files>'],
    tasks: 'reload'
  }
}

disusered avatar Nov 21 '12 01:11 disusered

Correct me if I'm wrong, but it seems there's no way to get it to ONLY refresh the CSS (when *.less) files change. Even with @disusered gruntfile it still reloads the entire page, right? You'd want it to just re-apply the latest CSS, not re-load the HTML/JS/location.reload()

Something like http://aboutcode.net/vogue/ but built as a grunt plugin

EDIT: looks like this can be done in https://github.com/ericclemmons/grunt-livereload

philfreo avatar Feb 25 '13 23:02 philfreo

Correct, this doesn't change the refresh settings, just reduces repeat/unneeded compiles and concats.

disusered avatar Feb 26 '13 08:02 disusered