Grunt手表运行“手表”任务等待 [英] Grunt watch Running "watch" task Waiting

查看:144
本文介绍了Grunt手表运行“手表”任务等待的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个grunt-watch的问题。当我在终端输出中使用grunt时
Running正在监视任务正在等待...

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ krp- arina @ krparina-Lenovo-G555:〜/ server $ grunt
运行watch任务
等待...
krp-arina @ krparina-Lenovo-G555:〜/ server $ grunt - v
初始化
命令行选项:--verbose

读取Gruntfile.jsGruntfile ... OK

注册Gruntfile任务。

注册grunt-contrib-less本地Npm模块任务。
读取/home/krp-arina/server/node_modules/grunt-contrib-less/package.json...OK
解析/ home / krp-arina / server / node_modules / grunt-contrib-less /package.json...OK
加载less.js任务...确定
+减

注册grunt-contrib-watch本地Npm模块任务。
读取/home/krp-arina/server/node_modules/grunt-contrib-watch/package.json...OK
解析/ home / krp-arina / server / node_modules / grunt-contrib-watch /package.json...OK
加载watch.js任务... OK
+ watch
阅读package.json ...确定
解析package.json。 ..OK
初始化配置... OK
加载Gruntfile.js任务... OK
+ default,w

未指定任务,运行默认任务。
运行任务:默认

运行默认任务

运行监视任务
等待...
验证属性监视是否存在在配置中... OK

但这没有任何作用,它只是结束。



我想在每次更改时编译更少。
这里是我的Gruntfile.js

  module.exports = function(grunt){
require('load -grunt任务)(咕噜);
//项目配置。

grunt.initConfig({
pkg:grunt.file.readJSON('package.json'),
less:{
dist:{
文件:{
'pd_wp / www / wp-content / themes / anarchy / css / commons.css':'pd_wp / www / wp-content / themes / anarchy / css / commons.less'
},
选项:{
compress:true,
cleancss:false
}
}
},
watch:{
选项:{
less:{
files:['pd_wp / www / wp-content / themes / anarchy / css / *。less'],
tasks:['less'] ,
//选项:{
// spawn:false
//}
}
}
}
});


//默认任务。
grunt.registerTask('w',['watch']);
grunt.registerTask('default',['watch']);

};

我使用
grunt-cli v0.1.13
grunt v0.4.5
grunt-contrib-less v1.0.0
grunt-contrib-watch v0.6.1
load-grunt-tasks v3.1.0

nodejs v0.12.1



有人告诉我我在做什么错误

解决方案

<我很确定你的问题在这里是你的json配置的顺序。但我可能是错的。文档列表
watch:{taskName:{options:{}}}




$ b

watch:{options:{taskName:{}}}



你试过这个:

  watch:{
less:{
files: ['pd_wp / www / wp-content / themes / anarchy / css / *。less'],
tasks:['less']
}
}

grunt-contrib-watch文档


I have a problem with grunt-watch. When I use "grunt" in terminal outputs "Running "watch" task Waiting..."

krp-arina@krparina-Lenovo-G555:~/server$ grunt
Running "watch" task
Waiting...
krp-arina@krparina-Lenovo-G555:~/server$ grunt -v
Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.

Registering "grunt-contrib-less" local Npm module tasks.
Reading /home/krp-arina/server/node_modules/grunt-contrib-less/package.json...OK
Parsing /home/krp-arina/server/node_modules/grunt-contrib-less/package.json...OK
Loading "less.js" tasks...OK
+ less

Registering "grunt-contrib-watch" local Npm module tasks.
Reading /home/krp-arina/server/node_modules/grunt-contrib-watch/package.json...OK
Parsing /home/krp-arina/server/node_modules/grunt-contrib-watch/package.json...OK
Loading "watch.js" tasks...OK
+ watch
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ default, w

No tasks specified, running default tasks.
Running tasks: default

Running "default" task

Running "watch" task
Waiting...
Verifying property watch exists in config...OK

But this does nothing, it just ends.

I want to compile less at each change. Here's my Gruntfile.js

module.exports = function(grunt) {
  require('load-grunt-tasks')(grunt);
  // Project configuration.

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    less: {
      dist:{
        files: {
          'pd_wp/www/wp-content/themes/anarchy/css/commons.css':'pd_wp/www/wp-content/themes/anarchy/css/commons.less'
        },
        options: {
          compress: true,
          cleancss: false
        }
      }
    },
    watch: {
      options: {
        less: {
          files: ['pd_wp/www/wp-content/themes/anarchy/css/*.less'],
          tasks: ['less'],
          // options: {
          //   spawn: false
          // }
        }
      }
    }
  });


  // Default task(s).
  grunt.registerTask('w', ['watch']);
  grunt.registerTask('default', ['watch']);

};

I use grunt-cli v0.1.13 grunt v0.4.5 grunt-contrib-less v1.0.0 grunt-contrib-watch v0.6.1 load-grunt-tasks v3.1.0

nodejs v0.12.1

Somebody tell me what am I doing wrong

解决方案

I'm pretty sure your issue here is the order of your json config. I may be wrong though. The docs list watch: { taskName: { options: {} } }

and you have

watch: { options: { taskName: {} } }

have you tried this:

watch: {
      less: {
          files: ['pd_wp/www/wp-content/themes/anarchy/css/*.less'],
          tasks: ['less']
      }
  }

grunt-contrib-watch docs

这篇关于Grunt手表运行“手表”任务等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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