Sass, Less, and Stylus, unified.

Unify

Unify is diamond's open API for writing cross-preprocessor plugins.


Easy

Unify has easy to understand, clear documentation.


Cross-platform

Any plugin written with Unify can be used with any preprocessor.

Unify Loves

Example

Install Unify:

npm i -S diamond-unify

Write JS using Unify:

// Require Unify
const unify = require('diamond-unify');

// Create a new PluginManager
const plugin = new unify.PluginManager();

// Create a new function called 'foo'
class Foo extends unify.FunctionController {
  // Called when the function 'foo' is called in Sass or Less
  handler() {
    // Return the color white
    return new unify.UColor(255, 255, 255);
  }
}

// Add 'foo' to our plugin
plugin.add(new Foo());

// Export our plugin
module.exports = plugin;

Add a Unify field to your diamond.json file:

{
  "unify": "path/to/your/js/file"
}

Then you can use the function in your Sass or Less like so:

#foo {
  color: foo();
}

Compile the Sass or Less with diamond:

diamond c path/to/file

Which will then generate CSS like this:

#foo {
  color: white;
}