What do you use to you share configuration between server and client?

30 views
Skip to first unread message

i...@bodokaiser.io

unread,
Oct 4, 2013, 6:43:30 AM10/4/13
to compo...@googlegroups.com
Hello,

I have a general configuration file which also includes urls for the client. I currently just do following to include it into a build.js

builder.build(funciton(err, res) {
  if (err) throw err;

  writeScript('window.config = ' + JSON.stringify(config) + res.require + res.js);
});

Unfortunately this is quite hacky and I would like to have something more like a native module I could require but I failed using something like this:

builder.hook('pre script', function(package) {
    package.addFile('scripts', 'boot/config.js', 'module.exports = ' + JSON.stringify(config));
});

As I did not manage to access it in the boot namespace (root works strangely...)

What do you guys use to solve the problem? Is there a package available?

Best,
Bodo
Reply all
Reply to author
Forward
0 new messages