guzart / gulp-ng-constant

Gulp plugin for dynamic generation of angular constant modules.
MIT License
109 stars 26 forks source link

Vinyl adapter option #9

Closed lukehorvat closed 9 years ago

lukehorvat commented 10 years ago

It seems to me that this gulp plugin should be completely usable without a physical file to source the constants from, because you can pass an object via the constants option. But the current setup doesn't really allow it.

I've added a noFile option that allows the plugin to act as a vinyl adapter, meaning it can be used in place of gulp.src. For example:

var gulp = require('gulp');
var ngConstant = require('gulp-ng-constant');
var uglify = require('gulp-uglify');
var constants = { hello: 'world' };

gulp.task('config', function () {
  return ngConstant({name: 'my.module.config', constants: constants, noFile: true})
    .pipe(uglify())  
    .pipe(gulp.dest('dist'));
});

The default outputted filename will be constants.js.

guzart commented 10 years ago

This is a great idea, and you are right, this is a potential use for the plugin.

It would be way better if we could automatically detect the use case, I would like the plugin to act smart but allow you to force the functionality with an option.

andidev commented 9 years ago

@guzart Any news on this?

andidev commented 9 years ago

For those who need this right away I have implemented this in https://www.npmjs.com/package/gulp-ng-constant-fork

guzart commented 9 years ago

@lukehorvat thank you for the PR, out in the wild on 0.3.0