Skip to content

grunt task to add the livereload javascript snippet to an html page

License

Notifications You must be signed in to change notification settings

dgrad/grunt-livereload-snippet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-livereload-snippet

Add livereload js snippet to html

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

Because it's not published on npm yet, add this git repo to your project's package.json file:

{
  "dependencies": {
    "grunt-livereload-snippet": "https://github.com/timdouglas/grunt-livereload-snippet/tarball/master"
  }
}

Once the plugin has been installed (npm install), it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-livereload-snippet');

The "livereload_snippet" task

Overview

In your project's Gruntfile, add a section named livereload_snippet to the data object passed into grunt.initConfig().

grunt.initConfig({
  livereload_snippet: {
    //task-specific options
    options: {
      hostname: 'localhost', //livereload hostname
      port: 35729, //livereload port
      add: true, //add to file
      before: '</body>', //location in document to add snippet, before this string
      //or:
      after: '<head>', //location in document to add snippet, after this string
    },
    remove: {
      //so you can remove the script snippet...
      options: {
        add: false
      },
      src: ['path/to/file.ext']
    },
  },
})

Options

options.hostname

Type: String Default value: localhost

The hostname for your livereload server.

options.port

Type: String Default value: 35729

Port for livereload server.

options.add

Type: Boolean Default value: true

Set this to false to remove the snippet from the file

options.before & options.after

Type: String Default value: undefined

If either is set, adds snippet before or after specified location in document. Otherwise, just adds snippet to end of file.

Release History

(Nothing yet)

About

grunt task to add the livereload javascript snippet to an html page

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%