56

I would like to know how I can prevent Sass from writing .map files. I'm using Sass in a very basic setup:

sass --watch style.scss:style.css

what parameters do I have to add to avoid Sass to generate map files?

supersize
  • 13,764
  • 18
  • 74
  • 133

6 Answers6

90

That depends on the implementation.

For node-sass and ruby-sass try this:

sass --sourcemap=none --watch style.scss:style.css

If you're using dart-sass the usage is --no-source-map:

sass --no-source-map --watch style.scss:style.css
matewka
  • 9,912
  • 2
  • 32
  • 43
  • thanks for your answer. Just for the clearance, can I somehow give this parameter once, that Sass remembers I never wanna have `.map` files? – supersize Jan 05 '15 at 14:17
  • 1
    You can't. Just like you can't make it remember any of the other options you give to the sass command. – cimmanon Jan 05 '15 at 14:22
  • @cimmanon I thought about something like a config file where I can set other default parameters too! – supersize Jan 05 '15 at 14:23
  • @supersize, there is one. It's called `environment.rb` and it's hidden deeply in sass installation folder. Right now I'm trying to figure out how to modify this configuration, though I'm not very familiar with Ruby language. I'll update my answer when I'll success. – matewka Jan 05 '15 at 14:31
  • @matewka thanks! Your answer is working btw, anyway it would be interesting to know how to disable it in general! – supersize Jan 05 '15 at 14:33
  • @supersize, I tried various things including overwriting core Sass gem methods, with no luck. Unfortunately, for some reasons the `:sourcemap` option doesn't work. I tried to test it together with another one (`options[:style] = :compressed`) which worked fine. I'm not very familiar with Ruby, so I couldn't figure out where there problem is... I guess, the best solution for now would be to switch to [Compass](http://compass-style.org/). It's a framework on top of Sass and beside some really nice mixins, it has a global configuration file. – matewka Jan 05 '15 at 16:23
  • @matewka thanks for looking this up. Its good to know that Compass has this options, I personally didn't know that it is build on Sass, which makes it quite interesting to me. – supersize Jan 05 '15 at 16:36
  • Won't work for me: `Invalid argument for -m flag: 'none'. Allowed arguments are: auto inline`. – Alex Aug 25 '22 at 08:18
15

it's works:

sass --watch --no-source-map input.scss output.css

with

1.8.0 compiled with dart2js 2.0.0-dev.66.0

Jaisa Ram
  • 1,687
  • 14
  • 21
3

I'm using sass version 1.13.2 compiled with dart2js 2.0.0 on Ubuntu and it's sass --no-source-map --watch [source].scss:[target].css

as --source-map enables source map and --no-source-map disables it.

Ahmed Kamal
  • 2,660
  • 3
  • 21
  • 36
  • I am using **sass version 1.23.7** compiled with **dart2js 2.6.1** on MacOs and it works like the way @ahmed mentioned. `sass --no-source-map --watch [source].scss:[target].css` – vsoni Jan 13 '20 at 18:35
  • I am using sass version 1.26.2 compiled with dart2js 2.7.1 on windows. The above solution works for me. Thanks @ahmed kamal. – Thameem Abdul Latheef C May 30 '20 at 15:10
1

Works:

sass --sourcemap=none style.scss style.css

Doesn't work, still generate .map file:

sass --update --sourcemap=none style.scss:style.css

So make sure you have no --update flag

Victor
  • 13,914
  • 19
  • 78
  • 147
Anatolii Pazhyn
  • 1,442
  • 13
  • 7
0

As default, the sourcemap is enabled for Dart Sass and if you add --no-source-map it will disable it.

Amir2mi
  • 896
  • 9
  • 13
0

It's now 2023, and the answers here led me to disabling the sourcemaps via PHPStorm 2020.1 and using its File Watchers facility (file/settings/tools/file watchers).

In the Arguments text box, I used the following, and the sourcemaps are now history.

--no-source-map $FileName$:../css/$FileNameWithoutExtension$.css

I hope this may help someone who, like me, was trawling the web for a couple of days for the solution.

Alan N
  • 181
  • 2
  • 8