Package Exports
- requirejs-config-file
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (requirejs-config-file) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
requirejs-config-file
A small api to read and write your requirejs config file
installation
npm install requirejs-config-fileusage
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'));
configFile.read(function(err, config) {
if (err) throw 'Something went really wrong: '+err.toString();
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'));
configFile.read(function(err, config) {
if (err) throw 'Something went really wrong: '+err.toString();
config.baseUrl = '/new';
configFile.write(function(err, config) {
if (err) throw 'Cannot write the config'+err;
});
});create
// CreateExample: creating a new config file
var configFile = new ConfigFile('path/to/new-config.js'));
configFile.createIfNotExists();
configFile.write(function(err, config) {
if (err) throw 'Cannot write the config'+err;
});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(function(err, config) {
if (err) throw 'Something went really wrong: '+err.toString();
config.baseUrl = '/new';
configFile.write(function(err, config) {
if (err) throw 'Cannot write the config'+err;
});
});