Browserify transform for node-config library
npm install config-browserify
Gruntfile.js
var configify = require('config-browserify');
// ...
{
// ...
browserify: {
options: {
transform: [configify]
}
}
// ...
}
package.json
{
"name": "mymodule",
"browserify": {
"transform": "config-browserify"
}
}
ClientSide.js (which will be bundled by browserify)
var config = require('config');
global.window && console.log(config.get('Client.testProperty')); // prints `hello!`
config/default.json
{
"Client": {
"testProperty": "hello!"
}
}
Client
level config properties can be accessible from client-side code (which is bundled by browserify)watchify
at the moment. The entire app must be restarted in order to get config properties which were modified since the server started.