Nonchalantly Performs Magic
Miss any of our Open RFC calls?Watch the recordings here! »

broccoli-plugin-adapter

1.2.1 • Public • Published

Broccoli Plugin Adapter

Build Status Dependency Status DevDependency Status Npm downloads Npm Version Git tag Github issues License

Broccoli plugin adapter. Allows easy implementation of broccoli plugins.

Example

'use strict'
 
const BroccoliPluginAdapter = require('broccoli-plugin-adapter')
 
const tag = require('./tag')
const Injector = require('./injector')
const livereload = require('livereload')
 
/**
 * Let your plugin extend BroccoliPluginAdapter
 **/
class BroccoliLivereload extends BroccoliPluginAdapter {
 
    constructor(inputNodes, options) {
        super(inputNodes, options)
    }
 
    /**
     * Override handle content to get access to file contents. Be aware that
     * to handle text files you have to encode the binary content.
     **/
    handleContent(path, content) {
        if (this._building) {
            return content
        }
 
        // Notify live reload server that file changed
        this._livereload.filterRefresh(path)
 
        const inject = this._injector.matches(path)
 
        if (inject) {
            return this._injector.inject(content)
        }
 
        return content
    }
}
 
module.exports = BroccoliLivereload

Installation

npm install broccoli-plugin-adapter --save-dev

License

This project is distributed under the MIT license.

Install

npm i broccoli-plugin-adapter

DownloadsWeekly Downloads

55

Version

1.2.1

License

MIT

Unpacked Size

9.98 kB

Total Files

7

Last publish

Collaborators

  • avatar