【问题标题】:grunt/compass producing empty destination stylesheetgrunt/compass 产生空的目标样式表
【发布时间】:2013-10-28 15:47:24
【问题描述】:

我正在计算咕噜声和指南针。我正在使用“grunt-contrib-compass”。

当我运行“grunt”并编辑我的 sass 时,grunt 报告:

文件“css/site.sass”已更改。 完成,没有错误。

但是,我的目标样式表是空的。

我想我缺少一个配置选项,它告诉 grunt 将 css 文件写入何处。但是我一直无法弄清楚如何完成配置。

这就是我所拥有的:

module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),


    compass : {
        dist: {
        options : {
        sassDir: 'sass',
        cssDir: 'css',
        imageDir: 'img',
        fontsDir: 'fonts',
        files : ['sass/*.sass'] ,
        watch : 'true',
        debugInfo: 'true',
        force : 'true'
        }
       }
    },

        watch: {
            sass: {
                files: ['css/*.css', '*.php', 'templates*.php'],
                tasks: ['compass']
            },

        options : {
        livereload: true,
        files: [
            'css/site.css', 'js/*.js', '*.html', 'templates/*.php',
            '*.php', 'assets/images/**/*.{png,jpg,jpeg,gif,webp,svg}'
        ]
        }
        }

    });

    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.registerTask('default',['watch', 'compass']);
}

【问题讨论】:

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


    【解决方案1】:

    From the docs:

    此任务要求您拥有 Ruby、Sass 和 Compass >=0.12.2 安装。如果您在 OS X 或 Linux 上,您可能已经拥有 Ruby 已安装;在终端中使用 ruby​​ -v 进行测试。当您确认 你已经安装了 Ruby,运行 gem update --system && gem install compass 安装 Compass 和 Sass。

    确保您已完成该操作。 Also, you didn't specify a target。也许只需将您的配置更改为此即可。

    compass : {
        dist: {
            options : {
                sassDir: 'css',
                cssDir: 'css',
                debug: 'true'
            }
        }
    },
    

    编辑:可能是您在手表配置中的内容覆盖了 sass 目标。试试这个:

        watch: {
            sass: {
                files: ['sass/**/*.sass'],
                tasks: ['compass']
            },
            css: {
                options: {
                    livereload: true;
                }
                files: ['css/**/*.css'],
                tasks: []
            }
        }
    

    【讨论】:

    • 嘿,本。我已经更新了我的问题中的配置。我已经安装、测试和工作了 ruby​​、compass 和 sass。恐怕将选项对象包装在“dist”中并没有产生任何不同。
    • Gruntfile 中的这一行是不必要的:grunt.registerTask('default',['watch', 'compass']); - 删除它并尝试简单地运行grunt watch。 (你的compass 任务永远不会运行,因为grunt watch 是一个阻塞任务)。
    猜你喜欢
    • 2011-11-10
    • 1970-01-01
    • 1970-01-01
    • 2013-07-21
    • 2021-06-02
    • 2014-08-03
    • 2015-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多