1.3.0 • Published 6 years ago

rollup-plugin-config v1.3.0

Weekly downloads
146
License
MIT
Repository
-
Last release
6 years ago

rollup-plugin-config

Build Status Coverage Status

Rollup plugin designed mainly for use with node-config (though you can pass any object you want).

Installation

Install the package:

  • npm npm install --save-dev rollup-plugin-config
  • yarn yarn add --dev rollup-plugin-config

Usage

Pass any object with a single root node to the plugin (it can be named anything you want).

import { rollup } from 'rollup'
import configPlugin from 'rollup-plugin-config'

	const configObject = {
		one: 1,
		two: 2,
		three: {
			four: 'four'
		}
	};
	
	rollup({
		entry: 'main.js',
		plugins: [
			configPlugin({CONFIG: configObject}) //Now you can use values like CONFIG.one or CONFIG.three.four in your code
		]
	})

Use that node name as a global variable in your script.

console.log(CONFIG.one + CONFIG.two)

It'll get replaced with an actual value from the object you provided.

console.log(1 + 2)
1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago