Socket
Socket
Sign inDemoInstall

rollup-plugin-config

Package Overview
Dependencies
50
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rollup-plugin-config

Plugin for Rollup to replace variables with values from configuration object (great to use with node-config)


Version published
Weekly downloads
8
increased by700%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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)

Keywords

FAQs

Last updated on 18 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc