1.0.7 • Published 2 years ago

rollup-plugin-json-combine v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago