Gruntjs grunt contrib连接grunt contrib手表和Chrome LiveReload扩展

Gruntjs grunt contrib连接grunt contrib手表和Chrome LiveReload扩展,gruntjs,livereload,grunt-contrib-watch,grunt-contrib-connect,Gruntjs,Livereload,Grunt Contrib Watch,Grunt Contrib Connect,嗨,我想知道是否有可能从Grunfile.js自动启用Chrome LiveReload扩展。我的意思是,当页面以grunt open打开时,不要单击工具栏中的LR扩展图标,也不要在html文件中添加livereload脚本 mypackage.json 我的Grunfile.js 为什么不使用watch任务的名称呢?您的意思是像watch:{options:{livereload:true},}?看起来您需要指定正在使用的端口,所以:options:{livereload:8000}。不管怎样

嗨,我想知道是否有可能从Grunfile.js自动启用Chrome LiveReload扩展。我的意思是,当页面以grunt open打开时,不要单击工具栏中的LR扩展图标,也不要在html文件中添加livereload脚本

mypackage.json 我的Grunfile.js
为什么不使用watch任务的名称呢?您的意思是像watch:{options:{livereload:true},}?看起来您需要指定正在使用的端口,所以:options:{livereload:8000}。不管怎样,我只是想知道为什么你需要Chrome扩展而不是这个选项?或者你呢?嗯,据我所知,没有Chrome扩展,你无法自动刷新页面。。。是这样吗?我的意思是,我把livereload:true和所有,但只要我不点击启用livereload,我看不到任何变化。很高兴听到它。。。也许写一个你如何解决问题的答案,然后接受它;
{
  "name": "dummy-project",
  "version": "0.1.0",
  "devDependencies": {
    "grunt": "~0.4.2",
    "matchdep": "~0.3.0",
    "grunt-contrib-watch": "~0.5.3",
    "grunt-contrib-compass": "~0.7.0",
    "grunt-open": "~0.2.2",
    "grunt-contrib-connect": "~0.6.0",
    "grunt-contrib-jshint": "~0.8.0"
  }
}
module.exports = function(grunt) {

  // Load Grunt tasks declared in the package.json file
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.initConfig({

    connect: {
      all: {
        port: 8000,
        protocol: 'http',
        hostname: 'localhost',
        base: '.',
        directory: null,
        keepalive: false,
        debug: false,
        livereload: true,
        open: true,
      },
    },

    compass: {
      dist: {
        options: {
          require: 'susy',
          sassDir: 'scss',
          cssDir: 'css',
          imagesDir: 'img',
          environment: 'production'
        }
      },
    },

    // grunt-watch will monitor the projects files
    watch: {
      gruntfile: {
        files: 'Gruntfile.js',
        tasks: ['jshint:gruntfile'],
      },
      sass: {
        files: ['scss/**/*.{scss,sass}'],
        tasks: ['compass']
      },
      css: {
        files: ['css/*.css'],
        options: {
          livereload: true,
        }
      },
      html: {
        files: ['**/*.html'],
        options: {
          livereload: true,
        }
      }
    },

    jshint: {
      gruntfile: {
        src: ['Gruntfile.js']
      }
    },

    open: {
      all: {
        // Gets the port from the connect configuration
        path: 'http://localhost:<%= connect.all.options.port%>'
      }
    },

  });

  grunt.registerTask('default', [
    'connect',
    'open',
    'watch'
  ]);
};