【问题标题】:sourcemap with grunt-sass points me to the wrong line带有 grunt-sass 的 sourcemap 将我指向错误的行
【发布时间】:2016-04-26 13:06:12
【问题描述】:

我使用 libass 和 susy,使用 grunt 和 compass-importer。 我的项目安装的基础来自 http://zellwk.com/blog/grunt-sass-with-susy/

在我更新文件之前一切正常,现在源映射不再向我提供 scss 文件中属性的确切行。 该示例已在印刷中。

sourmap 不是将我指向第 941 行,而是将我指向第 935 行

我的 grunt 文件是这样配置的:

// Grunt-sass 
sass: {
  app: {
    // Takes every file that ends with .scss from the scss 
    // directory and compile them into the css directory. 
    // Also changes the extension from .scss into .css. 
    // Note: file name that begins with _ are ignored automatically
    files: [{
      expand: true,
      cwd: 'scss',
      src: ['*.scss'],
      dest: 'css',
      ext: '.css'
    }]
  },
  options: {
   importer: compass,
   sourceMap: true, 
   outputStyle: 'nested', 
   imagePath: "../",
 }

【问题讨论】:

  • 插入选项:lineNumber: true ,如果修复我会更新我的答案

标签: sass source-maps libsass grunt-contrib-sass


【解决方案1】:

我认为是因为指向你的header是所有类的母亲。

你的标题正好是第 935 行。

你嵌套了很多类,你应该做最多 3 层和 50 行。

你的 grunt sass 有点混乱,你可以做更简单的事情:

//src ===============================
        var src;
        config.src = src = {
             sassMain        : 'scss/main.scss',
             distFolder      : 'public/stylesheets/lovelycss.dist.css',
             devFolder       : 'public/stylesheets/lovelycss.dev.css',
             sassFolder      : 'scss/**/*.scss',

        };




//distribution
                        sass.dist = {
                            options: { 
                                style: "compressed",
                                noCache: true, 
                                sourcemap: 'none', 
                                update:true
                            }
                            , files: {
                                "<%= src.distFolder %>" : "<%= src.sassMain %>"
                            }
                        };

                    //development env.
                        sass.dev = {
                            options: { 
                                style: "expanded", 
                                lineNumber: true,
                            }
                            , files: {
                                "<%= src.devFolder %>" : "<%= src.sassMain %>"
                            }
                        };

希望对你有帮助。

【讨论】:

  • 嗨,是的,这正是问题所在,它一直指向我所有班级的母亲,我需要了解为什么会发生这种情况以及如何解决它。恐怕以这种方式组织 grunt sass 并不能解决这个问题...... :(
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-22
  • 2015-03-23
  • 2014-08-10
  • 2019-02-24
  • 2019-08-02
  • 2015-05-18
  • 1970-01-01
相关资源
最近更新 更多