在Grunt sass中使用sourcemap功能时出错

时间:2014-06-04 09:02:10

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

我正在使用Grunt来观察我的sass文件集,并在使用grunt-contrib-sass插件进行更改时编译为css。我将sourcemap设置为true,因为我发现此功能在css调试中非常有用。

但是我收到以下错误消息:

Running "sass:uk" (sass) task
WARNING: Couldn't determine public URL for "C:\Ruby193\lib\ruby\gems\1.9.1\gems\compass-core-1.0.0.alpha.19\stylesheets\compass\reset\_utilities.scss" while generating sourcemap.
  Without a public URL, there's nothing for the source map to link to.

为什么会出现这种情况?

这是我的Gruntfile:

module.exports = function(grunt) {

grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    watch: {
        files: ['./style/v4/sass/**/*.scss'],
        tasks: ['sass:uk'],
        options: {
            spawn: false,
        },
    },
    sass: {
        uk: {
            options: {
                style: 'compressed',
                sourcemap: true,
                compass: true
            },
            files: {'./style/v4/css/screen.css': './style/v4/sass/screen.scss'}
        }
    }
});

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');

grunt.registerTask('default', ['watch']);

};

由于

2 个答案:

答案 0 :(得分:2)

我弄清楚造成这个问题的原因。我的ruby / compass / sass安装在我的PC的c:驱动器上,而我试图编译的sass文件在e:驱动器上。 Sass必须与您正在编译的文件安装在同一个驱动器上。当我在e:drive上重新安装ruby / sass / compass时,它运行正常。

答案 1 :(得分:2)

更新grunt-contrib-sass以使其适用于最新的Sass版本。更多信息:https://github.com/gruntjs/grunt-contrib-sass/issues/25