gulp-ng-config
gulp-ng-config copied to clipboard
Allow for no json file (and only inline values from gulp)
the use case i'm thinking of is pass a command line param to gulp and pass that directly to the plugin
gulpNgConfig('myApp.config', {
constants: {
apiUrl: argv.apiUrl
}
});
this would be especially nice since it allows you to avoid putting the value of your constants in source control, which is what drew me to this in the first place.
my workaround for the time being will be to create a json file that is just {}
Hi @ajwhite and @bdwain,
I'm thinking of contributing to this issue. Have one of you already started to think about it ?
Nope, feel free
i haven't either.
You can achieve this using buffer-to-vinyl.
var b2v = require('buffer-to-vinyl');
var gulpNgConfig = require('gulp-ng-config');
gulp.task('make-config', function() {
var json = JSON.stringify({
// your config here
});
return b2v.stream(new Buffer(json), 'config.js')
.pipe(gulpNgConfig('app.config'))
.pipe(gulp.dest('build'));
});
Is this worth putting in the readme? I can whip up a PR.
@psalaets great call, one of the beautiful things about streams is that we can & should be extremely modular and allow for single responsibility -- piping the result of that into gulpNgConfig
would be ideal here. We can add an "Additional Usages" section that shows how this can be integrated with other preceding or proceeding streams. I think this is a great entry to start off a new "Additional Usages" section. Feel free to PR!
that works, but it seems a little weird to me to require an extra module to read what you already have in code. It seems more logical to me to require something extra to read configs from a file (and default to only inline objects), though since it's already implemented this way, might not be worth changing.
When it comes to the principles behind a stream build system, a gulp plugin only serves as a stage (pipe) of the stream. To build around edges where there might not be a source of a stream, it kind of defeats the purpose of how a gulp plugin is intended to work -- there needs to be a stream source. The source, in this case, should be responsible for taking your command line args, creating your JSON object, and beginning a new readable stream.
Think I'm going to take a look at this for 1.4.0