【问题标题】:grunt-contrib-sass prevent sourcemapgrunt-contrib-sass 阻止源映射
【发布时间】:2014-10-19 23:01:05
【问题描述】:

我的 Grunt 设置使用 sass 将我的 .scss 文件编译为 src/.css 并使用 cssmin 将我的 src/.css 文件合并并缩小为 main.css。

我想在 SASS 中使用新的 sourcemap 功能,但我不确定它是否真的对我有用,因为 cssmin 会将我所有的 css 文件放入 main.css。

有人对此有任何见解吗?

我现在也在尝试关闭 grunt-contrib-sass 中的源映射,但它不需要。这是我的 Gruntfile.js 中的相关代码:

sass: {
  dist: {
    options: {
      sourcemap: 'none'
    },
    files: [{
      expand: true,
      cwd: 'stylesheets/scss',
      src: ['**/*.scss'],
      dest: 'stylesheets/src',
      ext: '.css'
    }]
  }
},

来自:github.com/gruntjs/grunt-contrib-sass

【问题讨论】:

  • 您使用的是什么版本的 grunt-contrib-sass?您可能需要升级。包作者在这里回答了类似的问题:github.com/gruntjs/grunt-contrib-sass/issues/153
  • 顺便说一句,您可以使用带有压缩值的输出选项来替换 cssmin。

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


【解决方案1】:

我刚遇到这个问题,其他解决方案对我没有帮助。这是我修复它的方法:

options: {
  "sourcemap=none": ''
}

使用 sass 版本 3.4.2,npm update 没有帮助

【讨论】:

  • ^ 此处相同。一个非常丑陋的配置选项,但至少它有效。
【解决方案2】:

添加 sourceMap: true 如下解决了我的问题(注意:我正在使用 grunt.loadNpmTasks('grunt.sass')):

sass: {
  options: {
    includePaths: ['bower_components/foundation/scss'],
    imagePath: '/images'
  },
  dist: {
    options: {
      outputStyle: 'nested',
      sourceMap: true
    },
    files: [{
    expand: true,
            cwd: 'scss',
    src: ['[^_]*.scss'],
    dest: '../public/css/',
    ext: '.css'
    }]
  }
}

希望对某人有所帮助。

【讨论】:

    【解决方案3】:

    我遇到了同样的问题。正如@imjared 在上述评论中所建议的那样,更新 grunt-contrib-watch 和 grunt-contrib-sass 就可以了。

    https://www.npmjs.org/doc/cli/npm-update.html

    【讨论】:

      猜你喜欢
      • 2013-06-21
      • 2016-01-07
      • 1970-01-01
      • 2023-03-12
      • 2017-10-15
      • 1970-01-01
      • 2016-04-08
      • 2014-12-24
      • 2014-04-16
      相关资源
      最近更新 更多