rave-load-json

0.5.1 • Public • Published

rave-load-json

Adds json loading to rave.js based on file extensions.

By default, rave-load-json loads json when it detects a '.json' file extension.

You can change this list by adding a loadJson rave env property. For example, to detect ".json" and ".config" extensions, add the following to your app's bower.json or package.json:

{
    "rave": {
        "env": {
            "loadJson": {
                "extensions": [ "json", "config" ]
            }
        }
    }
}

Usage

Importing a json file as a module is easy. Just import it as if it were a JavaScript module.

For CommonJS/node-formatted modules (or AMD-wrapped CommonJS):

var config = require('./config.json');
// ...
if (config.isMobile) { /* ... */ }

For classic AMD modules:

define(['./config.json'], function (config) {
    // ...
    if (config.isMobile) { /* ... */ }
});

For ES6-formatted modules:

import config from './config.json';
// ...
if (config.isMobile) { /* ... */ }

Package Sidebar

Install

npm i rave-load-json

Weekly Downloads

2

Version

0.5.1

License

MIT

Last publish

Collaborators

  • unscriptable