2013-07-22 35 views
4

我正在使用Yeoman RC1.1生成我的项目并已加载grunt-contrib-compass以在我的项目中使用Scss。使用Grunt Compass任务生成没有调试信息的生产CSS代码

当我执行grunt build时,生成的CSS会被缩小,但是会充满调试注释。它看起来像这样:

@media -sass-debug-info{filename{font-family:file\:\/\/\/\/Users\/myname\/Sites\/project\/app\/components\/sass-bootstrap\/lib\/_reset\.scss}line{font-family... 

当整个事情被污染了大量的-sass-debug-info代码。

在Gruntfile.js,我已经设置了以下选项(一堆其他选项中)打开调试的评论功能的/距离/ css文件:

grunt.initConfig({ 
    compass: { 
     dist: { 
      options: { 
       debugInfo: false 
      } 
     } 
    } 
} 

我是不正确的假设关闭debugInfo通过将其设置为false应该解决问题?

回答

0

尝试输出SYLE压缩https://github.com/gruntjs/grunt-contrib-compass#debuginfo和环境:生产

+0

我把'debugInfo'改为'outputStyle'和'environment',结果都一样:( – micah

+0

你有没有可能与设置冲突的config.rb? – nschonni

+1

我想通了。由于某种原因,在/ styles /目录下,我有一个包含所有这些调试注释的.css文件,所以咕噜咕噜地抓住了该目录中的所有内容并将它们压缩在一起 – micah

0

你必须在compass.server.options.debugInfo

compass: { 
    options: { 
    sassDir: '<%= yeoman.app %>/styles', 
    cssDir: '.tmp/styles', 
    generatedImagesDir: '.tmp/images/generated', 
    imagesDir: '<%= yeoman.app %>/images', 
    javascriptsDir: '<%= yeoman.app %>/scripts', 
    fontsDir: '<%= yeoman.app %>/styles/fonts', 
    importPath: '<%= yeoman.app %>/bower_components', 
    httpImagesPath: '/images', 
    httpGeneratedImagesPath: '/images/generated', 
    httpFontsPath: '/styles/fonts', 
    relativeAssets: false, 
    assetCacheBuster: false, 
    raw: 'Sass::Script::Number.precision = 10\n' 
    }, 
    dist: { 
    options: { 
     generatedImagesDir: '<%= yeoman.dist %>/images/generated' 
    } 
    }, 
    server: { 
    options: { 
     //set degbugInfo false to produce css code without sass debugInfo 
     debugInfo: false 
    } 
    } 
}, 
1

到debuginfo软的值更改为从真正的错误我碰到这个错误跑最近,问题是compass/grunt不会重新编译你的css文件,除非在被监视的文件中有一个改变。您不仅需要更新debugInfo:false,而且需要对scss文件进行更改,让它重新编译您的css文件,而无需调试信息内联。

+0

对我来说,谢谢:) –

-1

Grunt指南针使用位于“.tmp”的缓存。运行Grunt生成任务时,您应该清理此文件夹,或手动执行。

+0

为什么downvote没有任何解释?这个技术适用于我,只是想分享它。 –

相关问题