【问题标题】:manually running livereload in grunt?在 grunt 中手动运行 livereload?
【发布时间】:2014-04-08 22:03:23
【问题描述】:

我不得不在 grunt watch 中覆盖我的一个手表事件

grunt.event.on 'watch', (action, filepath, target) ->
# does something ...

如何在最后手动触发 livereload?

grunt.task.run('livereload'....)?

【问题讨论】:

    标签: gruntjs livereload


    【解决方案1】:

    我通过仅在我在进程结束时写入的一个文件上设置 livereload 来解决这个问题。

    这是一个例子:

    module.exports = (grunt) ->
    
      grunt.initConfig
        watch:
          reload:
            options:
              livereload: true
            files: "refresh.txt"
          css:
            files: ["**/*.css"]
          js:
            files: ["**/*.js]
        # ... and all your tasks
    
      grunt.event.on 'watch', (action, filepath, target) ->
        # does something ...
        if target isnt 'reload'
          data = "#{grunt.template.today("isoDateTime")}\n"
          require('fs').appendFileSync "refresh.txt", data
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-05
      • 2014-07-29
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多