【问题标题】:Grunt Watch not observing any changes to any file aside from html filesGrunt Watch 没有观察到除 html 文件之外的任何文件的任何更改
【发布时间】:2015-08-19 11:57:21
【问题描述】:

这是我的“监视”咕噜任务的基本视图:

module.exports = function(grunt){
    require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
    grunt.initConfig({
      watch: {
          options: {
            livereload: true,
          },
        gruntfile:{
            files:['gruntfile.js'],
            tasks:['default']
        },
        html: {
            files: ['index.html', 'assets/templates/*.html'],
            tasks: ['default']
        },
        js: {
            files: ['assets/js/*.js'],
            tasks: ['default']
        },
        sass: {
            options:{
                livereload:false
            },
            files:['assets/sass/*.scss'],
            tasks:['buildcss'],
        },
        css:{
            files:['assets/sass/*.scss'],
            tasks:[]
        },
      },
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.registerTask('default', ['htmlhint','buildjs', 'buildcss', 'browserSync', 'watch','serve']);
};

所以我有 buildcss 可以将我的 scss 编译并缩小为 master.css 文件。我设置了 watch 来观察 scss 的变化,运行 buildcss 任务,然后在 master.css 文件更新后运行默认任务。然后它应该刷新页面。 但是,每当我对 scss 文件进行更改并保存它时,终端不会显示任何文件更新,即使它显然是“正在查看文件......”。当我进行更改时,唯一显示为更新的文件是 html 文件:索引和模板。对我来说完全是无稽之谈。抱歉,我是第一次在这里配置 Grunt。

【问题讨论】:

    标签: sass gruntjs task watch


    【解决方案1】:

    我混淆了 watch 和 browserSync 而不是一起使用它们。首先,我必须将 watchTask: true 添加到 browserSync,然后我必须确保在 watch 之前调用 browserSync,然后我必须添加控制台提示我添加到 index.html 的代码的 sn-p。现在它完美地工作了。这是我用来找路的网站:http://blog.teamtreehouse.com/getting-started-with-grunt

    【讨论】:

      猜你喜欢
      • 2013-07-29
      • 2015-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多