Book Image

Mastering PostCSS for Web Design

By : Alex Libby
Book Image

Mastering PostCSS for Web Design

By: Alex Libby

Overview of this book

PostCSS is a tool that has quickly emerged as the future of existing preprocessors such as SASS and Less, mainly because of its power, speed, and ease of use. This comprehensive guide offers in-depth guidance on incorporating cutting-edge styles into your web page and at the same time maintaining the performance and maintainability of your code. The book will show how you can take advantage of PostCSS to simplify the entire process of stylesheet authoring. It covers various techniques to add dynamic and modern styling features to your web pages. As the book progresses, you will learn how to make CSS code more maintainable by taking advantage of the modular architecture of PostCSS. By the end of this book, you would have mastered the art of adding modern CSS effects to web pages by authoring high performing, maintainable stylesheets.
Table of Contents (21 chapters)
Mastering PostCSS for Web Design
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Linting and optimizing your code


Bandwidth usage has always been critical to the success of a website; remember the good old days of 56K modems? We've come a long way since then, but this is still no excuse for producing sites that swallow bandwidth like it's going out of fashion!

A part of this comes in the form of linting and minifying our style sheets before deploying into production use—it goes without saying that this should form part of any developer's workflow process by default. We can do this manually, but this manual job is prone to missing opportunities, which can lead to inconsistencies in our code.

Instead, we can use the power of PostCSS to perform the heavy lifting for us; the stylelint and cssnano plugin packs make for a powerful optimization facility! If we take a careful look at most gulp task files that we've created throughout the course of this book, both processes are taking place; in this example, stylelint is used at line 22, and cssnano at line 38:

Exploring the use...