【发布时间】:2016-07-20 09:58:14
【问题描述】:
我有以下 Gruntfile.js:
module.exports = function (grunt) {
"use strict";
grunt.initConfig({
watch: {
options: {
livereload: true
},
css: {
files: ["app.styles.css"]
},
js: {
files: ["app/**/*.js"]
},
html: {
files: ["index.html", "app/**/*.html"]
}
},
connect: {
server: {
options: {
port: 9000,
hostname: "*",
livereload: true,
open: true
}
}
},
jshint: {
files: ["app/**/*.js"]
}
});
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-connect");
grunt.registerTask("default", ["connect","watch"]);
};
我的应用程序中有以下结构:
请注意,app、bower_components、css 和图像都在同一级别。
当我运行任务 grunt --verbose 时,我看到我的应用程序中的更多文件/目录正在被监视,包括 bower_components 和 node_modules 目录。
但我没有指定 grunt 来查看这些文件/目录中的任何一个。最重要的是,当我修改配置中指定的 css 文件(app.styles.css)时,Grunt 不会重新加载应用程序。我认为 grunt 只查看了我在 Gruntfile.js 中指定的文件,这正是我想要的。为什么 Grunt 只关注这些额外的文件/目录,而没有关注我的 app.styles.css 文件?
【问题讨论】:
标签: gruntjs grunt-contrib-watch