Unify is diamond's open API for writing cross-preprocessor plugins.
npm i -S diamond-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;
diamond.json
file:{
"unify": "path/to/your/js/file"
}
#foo {
color: foo();
}
diamond c path/to/file
#foo {
color: white;
}