rollup-plugin-json-combine
v1.0.7
Published
Rollup plugin for combining multiple json'
Downloads
1,243
Readme
rollup-plugin-json-combine
Plugin combines json files from directory to one file.
Getting started
npm install --save-dev rollup-plugin-json-combine
or
yarn add rollup-plugin-json-combine --dev
Usage
import jsonCombine from 'rollup-plugin-json-combine';
export default {
...
plugins: [
jsonCombine({
input: ['path/*.json'],
fileName: 'path/output.json',
merge: (items) => {
const output = {};
items.forEach((item) => {
output[item.name] = item.res;
});
return output;
},
}),
],
...
};
Available options
input
: Path to directory with json's files, which need to combine.fileName
: Path and name final output json file.merge
: Callback function, which will apply to format final object. Return object, which will writes to output json. Get array of files data in format:
{
name: string, //name of input file
res: string // data of input file
}
It isn't required param, by default callback function sets:
(items) => Object.assign([...items])