Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I add the sass source map to my git repo?

Tags:

git

css

sass

I had added style.css.map to my .gitignore file thinking that this was some kind of internal file that was not needed for public consumption.

Now I'm seeing that when Chrome (not Firefox) loads my page, it is looking for style.css.map and returning a 404. I'm not explicitly asking it to load that file, but it seems to be getting called automatically.

  1. Why is Chrome looking for that file?
  2. Should I have included the .map file to the repo?

For further context, this is a Wordpress site and I am including the style.scss file in the repo.

like image 513
JakeParis Avatar asked Apr 29 '15 13:04

JakeParis


People also ask

What is a Sass source map?

A “source map” is a special file that connects a minified/uglified version of an asset (CSS or JavaScript) to the original authored version. Say you've got a file called _header. scss that gets imported into global. scss which is compiled to global.

Should you use source maps in production?

This is actually one of the easiest ways to increase your website performance. When you build your application for production, source maps are usually generated alongside your built files which are minified already. They hold the original sources of your code and helps in debugging your code live.

Is CSS map file necessary?

Removing CSS map files will not harm your application or make it work any differently. The same is true for JavaScript maps (i.e. . js. map ).

What is source map used for?

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.


1 Answers

  1. Using sourcemaps you can live edit the scss using the devtools.

For each generated CSS file, Sass is generating a source map file (.map file) in addition to the compiled CSS. Each CSS file contains an annotation that specifies the URL of its source map file, embedded in a special comment on the last line of the file:

/*# sourceMappingURL= */

More info about sourcemaps: https://developer.chrome.com/devtools/docs/css-preprocessors

  1. If you want to use sourcemaps on prod, you must have the .map file, if you don't need it, just disable its generation. If you are using grunt to run Sass, check your config.rb file and look for the sass_options entry, you might find ":sourcemap => true", if you find it, set it to false. Beware that sourcemaps are default on Sass 3.4.
like image 65
Luciano Santos Avatar answered Oct 31 '22 17:10

Luciano Santos