multibundle-mapper v1.0.0
multibundle-mapper
Writable stream that accepts r.js config objects and writes mapping/bundling meta data into provided file of specified format (json, js, html).
Example
var multibundle = require('multibundle')
, Mapper = require('multibundle-mapper')
, options = require('./options/bundles.js')
, config = require('./options/config.js')
;
// optimize
var bundler = multibundle(config, options);
var bundleMapper = Mapper.json('config/local.json', {prefix: config.prefix});
bundler.pipe(bundleMapper);
-
Mapper ⏏
Kind: Exported class
-
new Mapper(format, filepath, options, callback)
Creates writable stream attached to the provided endpoint (file) of the specified format.
Params
- format string - output file format
- filepath string - path to the output file
- options object - list of options to adjust Mapper's behavior
- callback function - invoked after all data has been written
-
mapper._toJson(callback)
℗
Writes bundles data into JSON file
Kind: instance method of Mapper
Access: private
Params
- callback function - invoked after file has been written
-
mapper._toJs(callback)
℗
Writes bundles data into JS file
Kind: instance method of Mapper
Access: private
Params
- callback function - invoked after file has been written
-
mapper._toHtml(callback)
℗
Writes bundles data into HTML file
Kind: instance method of Mapper
Access: private
Params
- callback function - invoked after file has been written
-
mapper._readAndWrite(file, callback)
℗
Checks if file exists and reads from it, otherwise passes empty content and writeFile function bound to the file
Kind: instance method of Mapper
Access: private
Params
- file string - file path to read
- callback function - invoked with file's content (or empty string) and write function
-
mapper._getPrefixedBundle(file)
⇒ string ℗
Composes prefixed file path for provided bundle local file
Kind: instance method of Mapper
Returns: string - prefix file name sans extension
Access: private
Params
- file string - bundle's file name
-
mapper._write(bundle, encoding, next)
℗
Receiver for the written data (underlying writeable stream interface)
Kind: instance method of Mapper
Access: private
Params
- bundle object - bundle metadata
- encoding string - encoding type for a chunk, ignored since expecting only objects
- next function - callback function
-
9 years ago