27
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

grunt-contrib-watchを使ってlivereloadする

Last updated at Posted at 2013-06-15

これまでgruntでlivereload(grunt-contrib-livereload)をするにはregarde(grunt-contrib-regarde)とlivereload(grunt-contrib-livereload)が必要だったみたいなんですが、watch(grunt-contrib-watch)の0.4からlivereloadがビルトインされたようなので、使ってみました。
確か、livereloadを入れようとすると「Deprecated in favor of grunt-contrib-watch which now have Livereload support built-in.」って怒られたはず。watchの0.4以降だとconnectとwatchがあればlivereloadできるみたいです。watch内の設定でlivereload: trueにします。

'use strict';
module.exports = function(grunt){

     grunt.initConfig({

           pkg: grunt.file.readJSON("package.json"),

           watch:{
                options: {
                     livereload: true
                },
                html: {
                     files: '*.html',
                     tasks: ['']
                }
           }, 

           connect: {
                livereload: {
                     options: {
                          port: 9001
                     }
                }
            }
     });

     grunt.loadNpmTasks("grunt-contrib-watch");
     grunt.loadNpmTasks("grunt-contrib-connect");

     grunt.registerTask("default", ["connect","watch"]);

};

watchのアップデートとブラウザにエクステンションを入れるのを忘れずに。

27
27
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?