Open alexewerlof opened 9 years ago
Hmm, would you care to take a stab at this?
sure.
Nconf is a in-memory/disk store which does a stellar job of storing values for IDs that look like this: foo:bar:baz.txt
. I translate /
to :
, which nconf likes, then I store the value, then later, I ask nconf for the value for that ID and write it to disk.
Take this example:
var path = 'foo/bar/baz';
var id = path.replace(file.base, '').split('/').join(':'); // 'foo/bar/bax.txt' => 'foo:bar:baz.txt'
var contents = "Hello world.";
nconf.set(id, contents);
nconf.get(id, contents);
// { foo: { bar: { baz: "Hello, world." } } }
Since nconf uses store.json
to persist contents to disk, I've created a guid to namespace the current project's data to avoid conflicts with other gulp tasks running in the same folder.
This plugin works great for us embedding .glsl files (and generally other source codes). However, we really need to embed binary files as well. Currently we use a base64 encoder to convert .raw file contents into json like this:
And then use your plugin to add the file contents into json:
However this two step process is tedious and error prone. It would be really awesome if the plugin could deal with binary files as well.