2013-07-22 33 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沒有任何解釋?這個技術適用於我,只是想分享它。 –

相關問題