One of the key benefits of the PostCSS ecosystem is its flexibility—it allows any developer to create any plugin, or adapt existing ones, as long as the license allows for further development!
To help retain a sense of consistency, the developer has issued a series of mandatory guidelines, which should be followed where practical:
:hover pseudo-class, then postcss-hover would be a good example.postcss.plugin method when creating plugins—you are then hooking into a common plugin API.node.source for each node, so that PostCSS can generate an accurate source map.result.warn instead to manage errors.package.json file—this is used for feedback about the PostCSS ecosystem.More details on these guidelines are available at https://github.com/postcss/postcss/blob/master/docs/guidelines/plugin.md.
In addition, it is likely that we will use a task runner of some description, such as Broccoli, Grunt, or Brunch, or as in our case, Gulp. To help retain that consistency, the developer has issued a series of guidelines that should be followed where appropriate:
config file, then it must always be written in JavaScript, and set to support functions in parameters.CssSyntaxError messages—not every developer is familiar with JavaScript! Instead, make sure any errors are handled gracefully.result.warnings() should be displayed by PostCSS runners; this can be facilitated by using the postcss-logs-warnings or postcss-messages plugins if needed.More details on these guidelines are available at https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md.
The guidelines provided for plugins are mandatory, but in some cases can be seen as a start point—for example, a change log should always be maintained, but it is up to the developer as to whether this is a HISTORY.md, CHANGELOG.md, or a GitHub Releases document. The trick here is careful planning, and to keep it simple—focus on the basics first, before moving onto more complex projects. We can then get accustomed to what must be provided as a minimum for each plugin, before extending it to cover task runner use.
Okay, let's change tack at this point: one of the guidelines we've covered states that every plugin should be tested as part of normal practice; now is a perfect opportunity to explore what this means in more detail.