【问题标题】:Grunt with compass not compiling用指南针咕噜咕噜不编译
【发布时间】:2013-12-30 03:24:36
【问题描述】:

您好,我是 grunt 的新手,在使用 compass 启动和运行它时遇到问题。

这是我的 Gruntfile:

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({

        //Read the package.json (optional)
        pkg: grunt.file.readJSON('package.json'),

        // Metadata.
        meta: {
            sassPath: 'templates/sass/',
            cssPath: 'public/css/',
        },

        // Task configuration.
        compass: {
            dist: {
                files: {
                    '<%= meta.cssPath %>*.css': '<%= meta.sassPath %>**/*.scss'
                }
            }
        },

    });

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-compass');

    // Default task.
    grunt.registerTask('default', ['compass']);

}

但是当我运行 grunt --verbose 时,我得到了这个:

...
Running "default" task

Running "compass" task

Running "compass:dist" (compass) task
Verifying property compass.dist exists in config...OK
Files: templates/sass/ie.scss, templates/sass/print.scss, templates/sass/screen.scss, templates/sass/style.scss -> public/css/*.css
Options: (none)
Nothing to compile. If you're trying to start a new project, you have left off the directory argument.
Run "compass -h" to get help.

Done, without errors.

所以它看起来像是看到了文件,甚至看到了将它们放在哪里......出了什么问题?

编辑:让人们知道最终答案...我以为我以前尝试过这个但没有成功,但今天早上我最终让它工作了:

    compass: {
        dist: {
              expand: true,
              cwd: '<%= meta.scssPath %>',
              src: ['{,*/}*.scss'],
              dest: '<%= meta.cssPath %>',
              ext: '.css'
        }
    },

编辑 2:好吧,我这辈子不知道为什么,但它只在 config.rb 存在时才有效......为什么 grunt 会使用 compass 配置是另一个问题......

【问题讨论】:

  • Grunt 不使用 Compass 配置,Compass 使用。 ;) Grunt 插件只是从 shell 运行 compass 命令。

标签: gruntjs compass-sass


【解决方案1】:

我认为问题在于您的目标文件。您必须指定一个实际文件,而不是 *.css。试着稍微调整一下你的配置:

compass: {
    dist: {
        files: {
            '<%= meta.cssPath %>compiled.css': '<%= meta.sassPath %>**/*.scss'
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-13
    • 1970-01-01
    • 2021-01-19
    • 1970-01-01
    • 2014-04-28
    • 1970-01-01
    • 2015-01-05
    • 2015-11-17
    相关资源
    最近更新 更多