requirejs-config-file

4.0.0 • Public • Published

requirejs-config-file Build Status

NPM

A small api to read and write your requirejs config file

installation

npm install requirejs-config-file

usage

require the constructor

var ConfigFile = require('requirejs-config-file').ConfigFile;

read

// Read: reading the config
var configFile = new ConfigFile('path/to/some/requirejs-config.js'));
 
var config = configFile.read();
 
console.log(config); // is an object with the found config

modify (read and write)

// Modify: reading and writing the config
var configFile = new ConfigFile('path/to/some/requirejs-config.js'));
 
var config = configFile.read();
 
config.baseUrl = '/new';
 
configFile.write();

create

// CreateExample: creating a new config file
var configFile = new ConfigFile('path/to/new-config.js'));
 
configFile.createIfNotExists();
 
configFile.write();

create or modify

// CreateAndModifyExample: reading and writing a maybe not existing config file
var configFile = new ConfigFile('path/to/new-config.js'));
 
configFile.createIfNotExists();
 
configFile.read();
 
config.baseUrl = '/new';
 
configFile.write();

/requirejs-config-file/

    Package Sidebar

    Install

    npm i requirejs-config-file

    Weekly Downloads

    731,913

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    40.1 kB

    Total Files

    27

    Last publish

    Collaborators

    • pscheit