SASS: How to remove /*# sourceMappingURL Comment

2020-07-06 06:48发布

问题:

I'm starting SASS watch from Windows command line. And FireFox developer Toolbar (with Show Sources) to see the .scss files.

Everything works fine, but I realized my final .css output file was added an extra final line like:

/*# sourceMappingURL=index.css.map */

As in my company i'm not allowed to leave this comment I'd like to know If I have to manually remove it everytime or is there any way to automatically remove it when I stop SASS Watch.

Issue, other than the manual removal of the line, is that I'm working with Git for version control, so just by starting SASS (--sass watch...) will make my .css file appear as Modified by GIT as the extra line is added (and therefore it shows up in files to be Committed)

回答1:

What you're seeing is the sourcemap, which maps CSS classes in the compiled CSS to the individual SASS files. As of SASS 3.4, sourcemaps are enabled by default. To disable them, use the --sourcemap=none and that line will no longer be added nor will a sourcemap be generated.

Your command will look something like this:

sass --watch --sourcemap=none path/to/sass:path/to/css