【发布时间】:2015-06-04 22:51:02
【问题描述】:
我对 grunt-watch 有疑问。当我在终端输出中使用“grunt”时 "正在运行"监视"任务等待中..."
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
但这什么也没做,只是结束了。
我想在每次更改时编译更少。 这是我的 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']);
};
我用 咕噜声-cli v0.1.13 咕噜声 v0.4.5 grunt-contrib-less v1.0.0 grunt-contrib-watch v0.6.1 加载-grunt-tasks v3.1.0
nodejs v0.12.1
有人告诉我我做错了什么
【问题讨论】:
-
我已经支持了这个问题,请问您是如何解决这个问题的,这是我的问题...stackoverflow.com/questions/49874258/…
标签: node.js gruntjs grunt-contrib-watch