Disable map files on SASS
Asked Answered
E

6

60

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?

Endmost answered 5/1, 2015 at 10:42 Comment(0)
P
98

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
Professional answered 5/1, 2015 at 14:2 Comment(8)
thanks for your answer. Just for the clearance, can I somehow give this parameter once, that Sass remembers I never wanna have .map files?Endmost
You can't. Just like you can't make it remember any of the other options you give to the sass command.Didst
@Didst I thought about something like a config file where I can set other default parameters too!Endmost
@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.Professional
@Professional thanks! Your answer is working btw, anyway it would be interesting to know how to disable it in general!Endmost
@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. It's a framework on top of Sass and beside some really nice mixins, it has a global configuration file.Professional
@Professional 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.Endmost
Won't work for me: Invalid argument for -m flag: 'none'. Allowed arguments are: auto inline.Yugoslavia
G
17

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

Grimonia answered 30/6, 2018 at 17:25 Comment(0)
A
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.

Annabell answered 17/11, 2018 at 16:31 Comment(2)
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].cssResinous
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.Brenda
W
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

Woofer answered 10/5, 2015 at 19:46 Comment(2)
thanks for adding this, I think this will help people!Endmost
Use sass --update --force --sourcemap=none style.scss:style.css. --force flag will force compilation even if destination css is newer than scssPinch
F
1

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.

Fortis answered 4/3, 2023 at 16:28 Comment(0)
F
0

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

Fawcett answered 24/10, 2021 at 18:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.