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

Making changes to our code


Although we've only covered a few ideas, there are nevertheless a fair few steps to go through; the key to this (and keeping your sanity!) is to complete each in blocks, and not all in one go.

The bulk of our changes will use existing tasks we've created in earlier demos; to this we will add the PreCSS library (from https://github.com/jonathantneal/precss), along with postcss-import and gulp-pixrem plugins. With this in mind, we'll make a start—our first task is to split the code into more manageable style sheets.

Splitting our style sheet

The critical part of this process is to split our style sheet—for this, we will use the postcss-import plugin, from https://github.com/postcss/postcss-import:

  1. We'll start, as always, by firing up a Node.js command prompt, then changing the working folder to the root of our project area.

  2. At the prompt, go ahead and enter this command, then press Enter:

    npm install postcss-import --save-dev
    
  3. Wait for Gulp to complete the installation...