JakeParis
JakeParis

Reputation: 11210

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

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.

Upvotes: 11

Views: 5584

Answers (1)

Luciano Santos
Luciano Santos

Reputation: 201

  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.

Upvotes: 9

Related Questions