【问题标题】:Grunt Watch not running Compass as secondary taskGrunt Watch 没有将 Compass 作为次要任务运行
【发布时间】:2016-01-28 20:47:06
【问题描述】:

我试图在我的watch 任务中包含对grunt-contrib-compass 的调用,但它没有注册对我的.scss 文件的任何已保存更改。 grunt compass 工作正常,grunt watch 按预期记录对 *.php 的所有其他更改。一个人在这里做错了什么?

gruntfile.js:

module.exports = function(grunt) {
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.initConfig({
        compass: {
            dev: {
                options: {
                    config: 'config.rb'
                } //options
            } //dev
        }, //compass
        watch: {
            options: { livereload: true },
            scripts: {
                files: ['/scripts/*.js'],
            }, //scripts
            sass: {
                files: ['/_sass/*.scss'],
                tasks: ['compass:dev']
            }, //sass
            html: {
                files: ['*.php']
            } //html
        } //watch
    }) //initConfig
    grunt.registerTask('default', 'watch');
} //exports

只是为了好玩,我的 config.rb:

css_dir = '/css'
sass_dir = '/_sass'
output_style = :nested

【问题讨论】:

    标签: sass gruntjs grunt-contrib-watch grunt-contrib-compass


    【解决方案1】:

    所有路径中的前导“/”都让你失望,将它们删除(从 gruntfile 和 config.rb 中):

    watch: {
        options: { livereload: true },
        scripts: {
          files: ['scripts/*.js'],
        }, //scripts
        sass: {
          files: ['_sass/*.scss'],
          tasks: ['compass:dev']
        }, //sass
        html: {
          files: ['*.php']
        } //html
    } //watch
    

    【讨论】:

      猜你喜欢
      • 2015-12-29
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      • 1970-01-01
      • 2013-05-25
      • 1970-01-01
      • 2014-11-06
      • 1970-01-01
      相关资源
      最近更新 更多