babel-plugin-inline-json

    2.1.0 • Public • Published

    babel-plugin-inline-json

    Build Status

    Inline values from a JSON file eg. a config file

    Does not work if the argument to require() is an identifier or a template literal

    Example

    config.json:

    {
      "foo": "bar"
    }

    In

    var foo = require('config').foo;

    Out

    var foo = "bar";

    Installation

    $ npm install babel-plugin-inline-json --save-dev

    Usage

    Via .babelrc (Recommended)

    .babelrc

    {
      "plugins": [["inline-json", {"matchPattern": "config"}]]
    }

    Via CLI

    $ babel --plugins inline-json script.js

    Via Node API

    require("babel-core").transform("code", {
      "plugins": [["inline-json", {"matchPattern": "config"}]]
    });

    Origin

    this is based on @mwilliams-change's babel-plugin-inline-json-config-values.

    Install

    npm i babel-plugin-inline-json

    DownloadsWeekly Downloads

    5,074

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    10.9 kB

    Total Files

    27

    Last publish

    Collaborators

    • gkatsev