3

I have been trying to reload the server if the any of the file changes. I can watch the files which has been changed but it does not reload my server.

GruntFile.js

module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
        all:{ 
            src:'**/*.js',
           }


},
concat: {
        options: {
            banner: '(function() {',
            footer: '})();'
        },
        releaseLocalHybrid: {
            src: ['config/config.local.js','lib/fuse.js','src/model.js','src/templates/hybrid.js','src/controller/hybrid.js'],
            dest: 'dist/widgets.js'
        }
},

uglify: {
        options: {
            banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
        },
        releaseLocalHybrid: {
            files: {
                'widgets.js': ['<%= concat.releaseLocalHybrid.dest %>']
            }
        }

},
connect:
    {
        server:
        {
            options:
            {
                hostname: 'localhost',
                port: 8082,
                base: {
                    path:'.',
                    options: {
                    index:'index.html',
                    maxAge: 300000
                  },

                },
                livereload: true
            }
        }
    },
  watch: {
    options: {
        livereload: true
        },
     concat: {
        files: 'config/*.js',
        tasks: 'jshint',
        options:
        {
            spawn:false
        },
      },
    }
});

grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [  'concat:releaseLocalHybrid','uglify:releaseLocalHybrid','connect', 'watch']);
grunt.registerTask('server', ['concat:releaseLocalHybrid','uglify:releaseLocalHybrid','connect','watch']);
};

Any suggestion or help will be grateful.

amdixon
  • 3,814
  • 8
  • 25
  • 34
iamsuman
  • 1,413
  • 19
  • 32

2 Answers2

2

I was watching all the files in watch so jshint:all keeps watching and doesnot livereload but if i watch releaseLocalHybrid it worked. Thanks every one.

iamsuman
  • 1,413
  • 19
  • 32
1

You need to specify a port for livereload. I have been using livereload options as :

watch: {
  less: {
    files : ['less/**/*.less']
  },
  css: {
    files: ['css/*.css'],
    options: {
      livereload: {
        port: 35750
      }
    }
  }
}
Saba
  • 3,418
  • 2
  • 21
  • 34
  • 1
    I have tried that one it's not working it shows the changed file once but later if i changed any file or same file its watch for jshint:all and doenot reload – iamsuman Apr 18 '15 at 13:24