rollup-plugin-config

    1.3.0 • Public • Published

    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)

    Install

    npm i rollup-plugin-config

    DownloadsWeekly Downloads

    87

    Version

    1.3.0

    License

    MIT

    Last publish

    Collaborators

    • wain-pc