grunt-livereload
Refresh your CSS (or page) with each save via LiveReload.
Last updated 8 years ago by ericclemmons .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install grunt-livereload 
SYNC missed versions from official npm registry.

grunt-livereload

Refresh your CSS (or page) with each save via LiveReload.

Getting Started

First, install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-livereload

Second, add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-livereload');

Documentation

Third, have livereload monitor changes to browser-accessible resources. This part is crucial, as CSS, if specified correctly, can be reloaded without refreshing the entire page.

// grunt.js
{
  ...
  livereload  : {
    options   : {
      base    : 'public',
    },
    files     : ['public/**/*']
  }
  ...
}

In this example, public/css/app.css will trigger a reload of the css/app.css resource only, while public/index.html will cause a full page refresh.

Finally, ensure your watch task doesn't process CSS at the same time it processes HTML, JS, and other resources that are being monitored:

// grunt.js
{
  watch: {
    somecss: {
      files: '**/*.css',
      tasks: ['copy:somecss']
    },
    js: {
      files: '**/*.js',
      tasks: ['concat']
    }
  }
}

Many people watch everything and run their build process each time. This is unecessarily slow and prevents LiveReload from being able to see when only the .css has changed. So, it's recommended that you watch different types of files and perform only what's necessary to rebuild those.

This way, CSS is copied/processed alone and LiveReload will seamlessly replace the styles in your page without refreshing the whole browser.

Changelog

v0.1.0

  • Initial release

License

Copyright (c) 2013 Eric Clemmons Licensed under the MIT license.

Current Tags

  • 0.1.3                                ...           latest (8 years ago)

4 Versions

  • 0.1.3                                ...           8 years ago
  • 0.1.2                                ...           8 years ago
  • 0.1.1                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 1
This Week 2
This Month 4
Last Day 1
Last Week 0
Last Month 2
Dependencies (3)
Dev Dependencies (1)

Copyright 2014 - 2016 © taobao.org |