linkedin / css-blocks

High performance, maintainable stylesheets.
http://css-blocks.com/
BSD 2-Clause "Simplified" License
6.33k stars 152 forks source link

Optional Preprocessors & library/application API contract. #432

Closed chriseppstein closed 4 years ago

chriseppstein commented 4 years ago

There is now a core data type for preprocessors that conditionally process a stylesheet. The motivation for this is to allow libraries to expose a preprocessor integration for their specific Sass + Eyeglass library.

This allows the library to maintain some semblance of control over how the compilation is performed, in case that is important to that module (E.g. the precision value for Sass or exposing assets via eyeglass).

There's a base class for libraries to use (DirectoryScopedPreprocessor), and a helper function for applications that integrates all of the preprocessor adaptors into a single processor that supplies sass, eyeglass, and application default options.

If the DirectoryScopedPreprocessor isn't sufficient for a library's needs, they can implement the PreprocessorProvider interface.

Applications can use the simpler, OptionalAdaptor function for creating their own optional adaptors for preprocessing their own block files in different ways.

The README for @css-blocks/eyeglass is updated to include boilerplate code that libraries and applications can use to get started.