Grunt-Live Reload无法与Grunt-Contrib-Watch配合使用

詹姆

当我使用更改它们时,我试图让Grunt重新加载我的js文件grunt-contrib-watch这是我的Gruntfile

module.exports = function(grunt) {

  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.initConfig({

     connect: {
      all: {
        options:{
          port: 9000,
          hostname: "0.0.0.0",
          base: 'app',
          keepalive: true,
          middleware: function(connect, options) {

            return [

              require('grunt-contrib-livereload/lib/utils').livereloadSnippet,

              connect.static(options.base)
            ];
          }
        }
      }
    },
    open: {
      all: {
        path: 'http://localhost:<%= connect.all.options.port%>'
      }
    },
    watch: {
      options: {
        livereload: true
      },
      js: {
        files: ['app/js/**/*.js'],
        tasks: ['jshint'],
      }
    }
  });

  // Creates the `server` task
  grunt.registerTask('server',[
    'open',
    'livereload-start',
    'connect',
    'watch'
  ]);
};

当我更改一个js文件时,没有任何反应。任何帮助都会很棒。

朱里扬

我以前没有尝试过livereloadSnippet在中间件中使用过,因此我不确定那里可能有什么问题。但是,如果您只需要常规的LiveReload设置,则可以使用插件livereload提供选项grunt-contrib-connect

require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

grunt.initConfig({
  connect: {
    all: {
      options:{
        port: 9000,
        hostname: '0.0.0.0',
        base: 'app',
        keepalive: true,
        livereload: true,
        open: true
      }
    }
  },
  watch: {
    options: {
      livereload: true
    },
    js: {
      files: ['app/js/**/*.js'],
      tasks: ['jshint']
    }
  }
});

grunt.registerTask('server',[
  'connect',
  'watch'
]);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Grunt-Live Reload无法与Grunt-Contrib-Watch配合使用

来自分类Dev

grunt-contrib-watch + grunt-rsync

来自分类Dev

如何仅在需要时使用grunt-contrib-watch和grunt-contrib-coffee编译CoffeeScript?

来自分类Dev

使用grunt-contrib-connect和grunt-contrib-watch进行实时重载

来自分类Dev

为什么grunt-contrib-watch livereload无法正常运作?

来自分类Dev

无法使用grunt-contrib-cssmin创建缩小的CSS文件

来自分类Dev

在凉亭中使用grunt-contrib-concat

来自分类Dev

带livereload的grunt-contrib-watch,带vs,不带grunt-contrib-connect,带livereload

来自分类Dev

grunt-contrib-watch + sass:如何指定目标文件?

来自分类Dev

grunt-contrib-watch:{tinylr:“ Welcome”,版本:“ 0.0.4”}

来自分类Dev

Gruntfile with grunt-contrib-watch, browserify, and hbsfy (handlebars) - Automate transform

来自分类Dev

grunt-contrib-watch未绑定递归错误

来自分类Dev

grunt-contrib-watch是否有不同的输出样式?

来自分类Dev

错误的CSS路径-Grunt的Live Reload问题

来自分类Dev

在asp.net-vnext和Visual Studio 15中使用Grunt-Contrib-Watch

来自分类Dev

使用globlob模式时grunt-contrib-concat的奇怪行为

来自分类Dev

使用grunt-contrib-connect指定标题

来自分类Dev

将杏仁与grunt-contrib-requirejs一起使用

来自分类Dev

阻止Grunt Contrib Uglify删除未使用的Javascript

来自分类Dev

如何使用grunt-contrib-uglify也gzip js文件?

来自分类Dev

使用globlob模式时grunt-contrib-concat的奇怪行为

来自分类Dev

grunt-contrib-connect仅与keepalive一起使用

来自分类Dev

使用grunt-contrib-handlebars版本问题预编译车把

来自分类Dev

使用grunt-contrib-connect和grunt-connect-rewrite删除文件扩展名

来自分类Dev

在Visual Studio 2013中使用Grunt(无grunt-contrib)来编译Bootstrap 3.1 LESS

来自分类Dev

在Visual Studio 2013中使用Grunt(无grunt-contrib)来编译Bootstrap 3.1 LESS

来自分类Dev

如何使用grunt http服务器访问区域设置json文件(grunt-contrib-connect)

来自分类Dev

grunt-contrib-sass无法编译CSS文件

来自分类Dev

grunt插件grunt-contrib-haml无法处理UTF-8符号

Related 相关文章

  1. 1

    Grunt-Live Reload无法与Grunt-Contrib-Watch配合使用

  2. 2

    grunt-contrib-watch + grunt-rsync

  3. 3

    如何仅在需要时使用grunt-contrib-watch和grunt-contrib-coffee编译CoffeeScript?

  4. 4

    使用grunt-contrib-connect和grunt-contrib-watch进行实时重载

  5. 5

    为什么grunt-contrib-watch livereload无法正常运作?

  6. 6

    无法使用grunt-contrib-cssmin创建缩小的CSS文件

  7. 7

    在凉亭中使用grunt-contrib-concat

  8. 8

    带livereload的grunt-contrib-watch,带vs,不带grunt-contrib-connect,带livereload

  9. 9

    grunt-contrib-watch + sass:如何指定目标文件?

  10. 10

    grunt-contrib-watch:{tinylr:“ Welcome”,版本:“ 0.0.4”}

  11. 11

    Gruntfile with grunt-contrib-watch, browserify, and hbsfy (handlebars) - Automate transform

  12. 12

    grunt-contrib-watch未绑定递归错误

  13. 13

    grunt-contrib-watch是否有不同的输出样式?

  14. 14

    错误的CSS路径-Grunt的Live Reload问题

  15. 15

    在asp.net-vnext和Visual Studio 15中使用Grunt-Contrib-Watch

  16. 16

    使用globlob模式时grunt-contrib-concat的奇怪行为

  17. 17

    使用grunt-contrib-connect指定标题

  18. 18

    将杏仁与grunt-contrib-requirejs一起使用

  19. 19

    阻止Grunt Contrib Uglify删除未使用的Javascript

  20. 20

    如何使用grunt-contrib-uglify也gzip js文件?

  21. 21

    使用globlob模式时grunt-contrib-concat的奇怪行为

  22. 22

    grunt-contrib-connect仅与keepalive一起使用

  23. 23

    使用grunt-contrib-handlebars版本问题预编译车把

  24. 24

    使用grunt-contrib-connect和grunt-connect-rewrite删除文件扩展名

  25. 25

    在Visual Studio 2013中使用Grunt(无grunt-contrib)来编译Bootstrap 3.1 LESS

  26. 26

    在Visual Studio 2013中使用Grunt(无grunt-contrib)来编译Bootstrap 3.1 LESS

  27. 27

    如何使用grunt http服务器访问区域设置json文件(grunt-contrib-connect)

  28. 28

    grunt-contrib-sass无法编译CSS文件

  29. 29

    grunt插件grunt-contrib-haml无法处理UTF-8符号

热门标签

归档