Concatenate files with source maps.
var fs = var path = var concat = var resolveSourceMapSync = resolveSourceMapSyncvar createDummySourceMap = var jsFiles = "foo.js" "subdir/bar.js" "../baz.js" jsFiles = jsFilesjsFiles { node node} var output = "subdir/bundle.js" var concatenated = concatenatedconcatenated var result = concatenated fsfs
Installation
npm install source-map-concat
var concat =
Usage
concat(files, options)
files
is an array of objects with the following properties:
code
: The contents of the file, as a string.map
: The source map of the file, if any, as an object, a string or anything with a.toJSON()
method (such as aSourceMapGenerator
). It could be taken straight from a compiler, be resolved using source-map-resolve or created using source-map-dummy.sourcesRelativeTo
: A path thatfile.map.sources
are relative to. Defaults to.
.
options
:
delimiter
: A string to insert between each file.process(node, file, index)
: A function to call on each file infiles
.node
is aSourceNode
. You could use this to wrap JavaScript files in IIFEs, for example.mapPath
: The path to where you intend to write the source map of the produced concatenated file. Defaults to.
.
The files in files
will be concatenated into a SourceNode
which is
returned. You may then modify this source node if you wish (node.add(...)
for
example). When you’re done, call node.toStringWithSourceMap()
, which returns
an object with a code
property containing the concatenated code, and a map
property containing the source map.