gruntjs - Watch only css changes with grunt -
i have basic project setup index.html , styles.css in root folder. want changes .css file cause automatic refresh in browser everytime click save. content of gruntfile.js:
module.exports = function(grunt) { // project configuration. grunt.initconfig({ pkg: grunt.file.readjson('package.json'), watch: { styles: { files: ['styles.css'], options: { livereload: true } }, }, }); grunt.loadnpmtasks('grunt-contrib-watch'); // default task(s). grunt.registertask('default', ['watch']); };
but, when run grunt watch
in cmd
, get:
>> file "styles.css" changed. warning: task "css" not found. use --force continue. aborted due warnings.
what doing wrong?
basically livereload declaration nested wrong, , discussed above "styles" erroneous, think should work you:
module.exports = function(grunt) { // project configuration. grunt.initconfig({ pkg: grunt.file.readjson('package.json'), watch: { livereload: { options: { livereload: true }, files: [ 'styles.css' ] } } }); grunt.loadnpmtasks('grunt-contrib-watch'); // default task(s). grunt.registertask('default', ['watch']); };
Comments
Post a Comment