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:
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
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.
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.
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.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With