rollup-plugin-json-merge

0.0.2 • Public • Published

rollup-plugin-json-merge

npm version Node.js CI License: MIT

🍣 A Rollup plugin to merge multiple JSON sources into one.

Install

Using npm:

npm i rollup-plugin-json-merge --save-dev

Using yarn:

yarn add rollup-plugin-json-merge -D

Usage

Create a rollup.config.js configuration file and import the plugin:

import merge from 'rollup-plugin-json-merge';
import { name, version, description } from './package.json';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs',
  },
  plugins: [
    merge({
      input: [{ name, version, description }, 'src/manifest.json', 'src/data/*.json'],
      fileName: 'manifest.json',
    }),
  ],
};

Then call rollup either via the CLI or the API.

The configuration above will collect JSON values from given input option and build the output file using Object.assign.

Options

input

Type: (String | JSONValue) | Array[...(String | JSONValue)]
Default: []

Glob style string pattern or a JSON object or an array of a mix of those to construct a single output from.

fileName

Type: String
Default: output.json

Output filename for the merged JSON.

merge

Type: Function
Default: (items) => Object.assign(...items)

The function responsible for merging given items.

License

MIT

/rollup-plugin-json-merge/

    Package Sidebar

    Install

    npm i rollup-plugin-json-merge

    Weekly Downloads

    39

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    6.75 kB

    Total Files

    5

    Last publish

    Collaborators

    • karolis.sarapnickis