咕噜咕噜的手表和手写笔

grunt watch and stylus

本文关键字:手写笔 手表      更新时间:2023-09-26

无法弄清楚嵌套咕噜咕噜手表手写笔编译器(livereload稍后会推出)

我也尝试使用"新"咕噜声更新器,但我的代码中一定有问题。

有什么建议吗?

grunt.initConfig({
  stylus: {
    compile: {
      options: {
        paths: ['stylus'],
        import: [      
          'nib/*'
        ]
      },
      files: {
        'css/style.css': 'stylus/style.styl', 
      },
    },
  },
  watch: {
    stylus: {
      files: ['*/*.*'],
      task: ['newer:stylus:compile'],
      options : { livereload: true },
    },
  },
});

grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-newer');
grunt.registerTask('compile', ['newer:stylus:all']);

另外,如果我运行grunt watch,它工作得很好,但什么都不做。而且,如果我运行grunt stylus,它可以完美地编译我的 css。

好吧,在您的原始代码中,您正在使用选项task何时应该tasks(复数)。这将是我的第一个猜测。

watch: {
  stylus: {
    files: ['*/*.*'],
    tasks: ['stylus:compile'],   // This needs to be "tasks" (not "task")
    options : { livereload: true },
  },
},

我也不认为你需要前面的newer位。

我自己解决了,但我无法弄清楚错误是什么。

pkg: grunt.file.readJSON('package.json'),
        stylus: {
            all: {
                options: {
                      paths: ['stylus'],
                      import: [      //  @import 'foo', 'bar/moo', etc. into every .styl file
                        'nib/*'
                      ]
                    },
                    files: {
                      'css/style.css': 'stylus/style.styl', // 1:1 compile
                    },
            },
        },
        watch: {
            files: [
                'stylus/*.styl',
            ],
            tasks: ['stylus:all'],
        }
      });