Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sourceMapRootpath to have sourcemaps using LESS

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

like image 537
sebazelonka Avatar asked Dec 19 '13 16:12

sebazelonka


People also ask

What is the use of sourcemap?

A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.

What is sourcemap JavaScript?

A Sourcemap is a file that maps from the transformed source to the original source. It is a mapping between the generated/transpiled/minified JavaScript file and one or more original source files. The main purpose of Sourcemaps is to aid debugging.

What is. map file in JavaScript?

The . map files are for JavaScript and CSS (and now TypeScript too) files that have been minified. They are called source maps. When you minify a file, like the angular. js file, it takes thousands of lines of pretty code and turns it into only a few lines of ugly code.


1 Answers

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'
like image 183
Eric Avatar answered Sep 23 '22 06:09

Eric