Barleby
Barleby

Reputation: 688

SASS: How to remove /*# sourceMappingURL Comment

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)

Upvotes: 14

Views: 15276

Answers (2)

xerx593
xerx593

Reputation: 13261

In current Sass:

sass --no-source-map ...

Usage

$ sass --version && sass --help
1.44.0
Compile Sass to CSS.

Usage: sass <input.scss> [output.css]
       sass <input.scss>:<output.css> <input/>:<output/> <dir/>

=== Input and Output ===================
    --[no-]stdin               Read the stylesheet from stdin.
    --[no-]indented            Use the indented syntax for input from stdin.
-I, --load-path=<PATH>         A path to use when resolving imports.
                               May be passed multiple times.
-s, --style=<NAME>             Output style.
                               [expanded (default), compressed]
    --[no-]charset             Emit a @charset or BOM for CSS with non-ASCII characters.
                               (defaults to on)
    --[no-]error-css           When an error occurs, emit a stylesheet describing it.
                               Defaults to true when compiling to a file.
    --update                   Only compile out-of-date stylesheets.

=== Source Maps ========================
    --[no-]source-map          Whether to generate source maps.
                               (defaults to on)
    --source-map-urls          How to link from source maps to source files.
                               [relative (default), absolute]
    --[no-]embed-sources       Embed source file contents in source maps.
    --[no-]embed-source-map    Embed source map contents in CSS.

=== Other ==============================
-w, --watch                    Watch stylesheets and recompile when they change.
    --[no-]poll                Manually check for changes rather than using a native watcher.
                               Only valid with --watch.
    --[no-]stop-on-error       Don't compile more files once an error is encountered.
-i, --interactive              Run an interactive SassScript shell.
-c, --[no-]color               Whether to use terminal colors for messages.
    --[no-]unicode             Whether to use Unicode characters for messages.
-q, --[no-]quiet               Don't print warnings.
    --[no-]quiet-deps          Don't print compiler warnings from dependencies.
                               Stylesheets imported through load paths count as dependencies.
    --[no-]verbose             Print all deprecation warnings even when they're repetitive.
    --[no-]trace               Print full Dart stack traces for exceptions.
-h, --help                     Print this usage information.
    --version                  Print the version of Dart Sass.

(In (e.g.) sass-maven-plugin (and its forks)):

-DomitSourceMapingUrl=true

Upvotes: 0

allejo
allejo

Reputation: 2203

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

Upvotes: 12

Related Questions