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

Dissecting the architecture of a standard plugin


Creating a PostCSS plugin is a straightforward process—the beauty of PostCSS is that we as developers are free to design and construct any plugin we desire; it does mean that not every plugin will be of the same quality as others!

This aside, the recommended way to construct any PostCSS plugin is to use the boilerplate code, which is available from https://github.com/postcss/postcss-plugin-boilerplate; we can see an example of it in this screenshot:

If we explore the source code for any PostCSS plugin hosted in GitHub, there will be a host of different files present; not all of them will be the same for each different plugin!

Nonetheless, if we delve in deeper, there are some files we would expect to see as part of the architecture of any plugin; they are as follows:

  • index.js: This contains the main functionality for each plugin

  • package.json: This is used to configure and manage locally installed NPM packages

  • test.js: This contains the tests...