Grunt Watch反复显示“警告:必须提供模式” [英] Grunt Watch repeatedly showing "Warning: must provide pattern"

查看:144
本文介绍了Grunt Watch反复显示“警告:必须提供模式”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法配置Grunt来查看我的项目文件,重建和更新连接服务器中托管的页面。如果我运行任何构建任务,然后'watch'作为组合任务的一部分,那么'watch'似乎陷入了循环,无休止地打印消息。

I'm having trouble configuring Grunt to watch my project files, rebuild and update a page hosted in a connect server. If I run any of the build tasks and then 'watch' as part of a combined task, then 'watch' seems to get stuck in a loop, endlessly printing the message.

Running "watch" task
Waiting...
Warning: must provide pattern

如果我只是运行 $ grunt watch ,它会愉快地观察我的源文件并编译/构建。

If instead I just run $ grunt watch, it will happily watch my source files and compile/build as appropriate.

我认为相关的任务配置如下:

I think the relevant task configurations are these:

watch: {
  html: {
    files: [ '<%= site.partials %>', '<%= site.layouts %>', '<%= site.pages %>' ],
    tasks: [ 'html' ]
  },
  sass: {
    files: [ '<%= site.src %>sass/*.scss' ],
    tasks: [ 'styles' ]
  }
},

// development server
connect: {
  options: {
    port: 8080,
    livereload: 35729,
    hostname: 'localhost',
  },
  dev: {
    options: {
      directory: 'build',
    }
  }
},

和任务定义:

grunt.registerTask( 'build', [ 'styles', 'html', ] );
grunt.registerTask( 'default', [  'build','connect:dev', 'watch' ] );

'styles''html'任务运行grunt-sass和汇编。如上所述,运行任何这些任务,甚至单独'watch'都会产生预期的结果。这表明我的配置对象已正确定义 site.partials site.dest 等。问题只发生在我运行任何任务然后'watch'时,就像默认任务一样。

The 'styles' and 'html' tasks run grunt-sass and assemble. As stated above, running any of these tasks, or even 'watch' on its own yields the expected results. This suggests my config object has site.partials, site.dest etc defined correctly. The problem only happens when I run any task and then 'watch', as in the default task.

推荐答案

当我编辑我的Gruntfile并将一个字段(应该有一个文件模式)留空时,我刚刚遇到了类似的问题。

I just encountered a similar problem when I had been editing my Gruntfile and left a field (that should have had a file pattern) blank.

检查您的Gruntfile是否有空文件字段。

Check your Gruntfile for an empty file field.

在我的具体示例中:

wiredep: {
    options: {
        overrides: {
          "jquery-ui": {
              "main": [
                 "jquery-ui.js",
                 "themes/base/jquery-ui.css",
                 ""
              ]
          }
        }
    }
}

注意上面的空字符串。这产生了一个与你非常相似的错误。不幸的是,Grunt似乎没有告诉你哪里错误。您只需手动扫描Gruntfile即可找到错误。

Note the empty string above. That generated an error very similar to yours. It seems that Grunt doesn't tell you where the error is, unfortunately. You'll just need to scan through your Gruntfile manually to find the error.

这篇关于Grunt Watch反复显示“警告:必须提供模式”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆