liveBook · Manning

CSS preprocessor

As explained in Tiny CSS Projects

A CSS preprocessor is a tool that extends stylesheet authoring and transforms preprocessor source into CSS.

A CSS preprocessor extends stylesheet authoring with additional functionality, then transforms its own source syntax into CSS for the browser. Preprocessors aim to make styles easier to read and maintain, but they add a build step. section 1.1.2 section 12.0

Common choices and practical considerations include:

  • Sass, Less, and Stylus extend existing CSS functionality with their own syntaxes. section 12.0
  • Most implementations preprocess styles before serving the resulting CSS to the browser. section 12.0
  • Choose based on required functionality, team knowledge, and framework support, while accounting for the changed build-and-deploy process. section 12.8

Style a how-to article with Sass

Start with the article’s HTML and an SCSS stylesheet. Run Sass through npm, or use CodePen by placing the HTML in the HTML panel, copying the starting SCSS into the CSS panel, and selecting SCSS as the CSS preprocessor. The resulting CSS styles the page in the browser. section 12.1 section 12.1.3

Figure 12.1 Preprocessor sentiment (data source http://mng.bz/8ry2)

Compare preprocessor sentiment data when considering Sass alongside other preprocessor choices. section 12.0

How Tiny CSS Projects covers it

How deep it goes
Defines compilation and setup, demonstrates Sass use, and stops short of surveying most preprocessor features.
Examples
Uses a how-to article, Sass output, npm, CodePen, and SCSS configuration as concrete examples.
What it assumes
Assumes familiarity with plain CSS authoring while providing an alternate CodePen path for readers unfamiliar with npm.
What you can do after
Operate Sass through npm or configure SCSS in CodePen to compile preprocessor styles into browser-ready CSS.
How it connects
Connects CSS with Sass, Less, Stylus, SCSS syntax, npm, CodePen, and build processes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.