Creating Plugins

Acetate has support for distributing code via NPM as a plugin. For an example of a simple plugin you can look at the source code for acetate-asset-revisions

acetate.config.js

var assetRevisions = require('acetate-asset-revisions')

module.exports = function(acetate){
  acetate.use(assetRevisions({
    manifest: 'build/assets.json'
  }));
};

To use a plugin simply pass a a function to acetate.use. That function will get the acetate object as its first argument and can call additional helpers. For example

my-plugin.js

module.exports = function (options) {
  // anything you want your plugin to do one per config phase can be done here

  return function (acetate) {
    // call any configuration methods you need for your plugin
  }
};

acetate.config.js

// require plugin as a module
var myPlugin = require('my-plugin');

module.exports = function(acetate){
  // call myPlugin which returns an acetate configuration function
  acetate.use(myPlugin({
    // options
  }));
};

Edit this Page on GitHub