rollup-plugin-json-combine
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

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])

Readme

Keywords

Package Sidebar

Install

npm i rollup-plugin-json-combine

Weekly Downloads

661

Version

1.0.7

License

MIT

Unpacked Size

18.2 kB

Total Files

6

Last publish

Collaborators

  • vladimir.kovalchuk