5

I'm trying to have sourcemaps on my project. I'm using LESS, compiled with Grunt using grunt-contrib-less

Here is the code I have on my gruntfile.js:

less: {
  development: {
    options: {
      paths: ["assets-src"],
      // LESS source maps
      // To enable, set sourceMap to true and update sourceMapRootpath
         based on your install
      sourceMap: true,
      sourceMapFilename: 'assets-src/desktop/css/desktop.css.map',
      sourceMapRootpath: 'assets-dist/desktop/css/'
    },
    files : {
      "assets-src/desktop/css/desktop.css" :
      [
      "assets-src/desktop/less/reset.less",
      "assets-src/desktop/less/variables.less",
      "assets-src/desktop/less/mixins.less" 
      ]
    }
  }
 }

And this is the file's structure I have:

enter image description here

I have problems defining the sourceMapRootpath. I tried putting the same folder where all .LESS files are, but nothing happends, the same using the folder where .CSS files are.

Any idea on this?

Thanks! seba

4

2 に答える 2

6

I just solved this issue by setting to true the parameter "outputSourceFiles". You have to add this param. Because the sourceMapping of LESS is related to your express server root. I'm almost sure yours is assets-dist. By the way, you should have this in your gruntfile :

enter code here
      outputSourceFiles: true, // with this param you'll have your less in your map and you can see it
      sourceMap: true,
      sourceMapFilename: 'path/to/your/map', 
      sourceMapURL: '/complete/url/to/your/map', 
      sourceMapBasepath: 'public'
于 2014-03-16T20:13:09.077 に答える
0

grunt-contrib-less同じ問題が発生したため、古いバージョンの を使用していると仮定します。リリース履歴を見ると、ソース マップのサポートが LESS に追加されたのはごく最近のことです。

package.jsonファイルを検査し、grunt-contrib-lessバージョンが最新0.9.0バージョンを取得することを確認してから、 npm install.

于 2014-01-15T17:16:02.747 に答える