Grunt Watch没有将Compass作为次要任务运行

时间:2015-10-28 21:26:21

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

我正在尝试在grunt-contrib-compass任务中添加对watch的调用,但它没有注册任何已保存的.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

1 个答案:

答案 0 :(得分:0)

您的领导' /'在你所有的路径中都把你抛弃,删除它们(都来自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