Ember CLI Preprocessor Registry

5.0.1 · active · verified Wed Apr 22

Ember CLI Preprocessor Registry (npm: `ember-cli-preprocess-registry`) is an internal utility package within the Ember CLI ecosystem, providing a centralized registry for managing various preprocessors for `css`, `template`, and `js` assets. It is currently at version 5.0.1 and primarily maintained as needed for Ember CLI development, without a strict independent release cadence. Its key differentiator is its deep integration into Ember CLI's build pipeline, offering a standard way for addons to register and interact with asset transformations via hooks like `setupPreprocessorRegistry`. This package is not typically consumed directly by end-user applications but is a core component for Ember CLI addons wishing to extend asset compilation.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how an Ember CLI addon uses the `setupPreprocessorRegistry` hook to add a custom JavaScript preprocessor to the build pipeline.

module.exports = {
  name: 'special-js-sauce',
  
  setupPreprocessorRegistry(type, registry) {
    if (type !== 'parent') { return; }

    registry.add('js', {
      name: 'special-js-sauce-preprocessor',
      toTree(tree) {
        console.log('Processing JavaScript tree with special-js-sauce-preprocessor');
        // In a real scenario, 'tree' would be a Broccoli node and processing
        // would return a new Broccoli node. For demonstration, we return it as is.
        return tree;
      }
    });
    
    console.log('Registered special-js-sauce-preprocessor for type "js"');
    const jsPlugins = registry.load('js');
    console.log(`Current JS plugins: ${jsPlugins.map(p => p.name).join(', ')}`);
  }
};

view raw JSON →