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!"
}
}
- For security purposes, only the
Client
level config properties can be accessible from client-side code (which is bundled by browserify) - For support for server-side rendering frameworks, there is no support for
watchify
at the moment. The entire app must be restarted in order to get config properties which were modified since the server started.