Chapter 9 Preprocessors
9. Preprocessors
AuthoringCSScanbetedious.There’sasetofrepeatedcolorsandfontstomanage
andremember.Weneedtokeeptrackofvendorprefixes.Andsometimeswewant
todotasks,suchasnestingorgroupingrules,thatarebeyondthenativecapabilities
ofCSS.
Thisiswherepreprocessorscomeinhandy.Preprocessorsaddsyntaxcapabilities
andfeaturesthatCSSlacks:mixinsmakeitabreezetomanagevendorprefixes;
built-infunctionssaveusfromunitandcolorconversions;andtheabilitytoextend
aselectorletsusconsolidatestylerules.
Asthenamesuggests,preprocessorstakeaspecialsyntaxandcompileittoCSS.
TheyaretoolsforwritingCSS,althoughsometoolsalsohandleminificationand
concatenation.
Inthischapter,we’lllookattwooftheleadingCSSpreprocessortools:Less^1 and
Sass.^2 Thesearenottheonlypreprocessorsinexistence,buttheyarebyfarthemost
(^1) http://lesscss.org/
(^2) http://sass-lang.com/