-
Couldn't load subscription status.
- Fork 8
CSS JS Processor Interface
CSS/JS processors can be used to pre-compile stylesheets and JavaScripts in Brick.JS.
To enable your processor, the processor instance should be registered into brick-asset. See: https://github.com/brick-js/brick-asset/blob/master/index.js That means a pull-request to brick-asset/index.js is needed.
Processors are registered for specific file extensions. It's possible for a processor instance to be registered for multiple file extensions.
// file: brick-asset/index.js
var processor = ...
Processor.register('.less', processor, root);The registration of CSS and JS processors are the same.
The processor instance registered above should be an Object with .render() method:
Promise<String> processor.render(path, classPrefix)
The .render() should accept the CSS source file path,
the intended classPrefix given by Brick.JS,
and return a Promise that resolve as the result CSS String.
The default CSS Processor is: https://github.com/brick-js/brick-asset/blob/master/processor/css.js
The processor instance registered as a JavaScript processor should also be an Object with .render() method:
Promise<String> processor.render(path, moduleId)
The processor shall accept the script path, current moduleId,
and return a Promise that resolves as the result JavaScript String.
The default JavaScript Processor is: https://github.com/brick-js/brick-asset/blob/master/processor/js.js
Now available processors:
- brick-less: LESS Processor for Brick.JS.