miickel / gulp-angular-templatecache

Concatenates and registers AngularJS templates in the $templateCache.
MIT License
525 stars 103 forks source link

Way to build without templates.js file? #54

Closed olsonpm closed 9 years ago

olsonpm commented 9 years ago

So I'm using angular + browserify and ideally this templates.js file would be completely transparent (meaning it only shows up in the browserify bundled js output). The reason I say that would be ideal, is because it is essentially a build artifact, and thus should not be versioned.

What I would like to do is append the contents to the browserify entry file prior to bundling, but I'm new to all this and can't figure out whether that's even possible.

I would appreciate your thoughts on how to accomplish this if it is possible.

Thanks, Phil

miickel commented 9 years ago

Not sure exactly how it would work with Browserify (maybe you should post your issue on their github instead?), but you can always merge streams using the merge-stream module (NPM).

Here's a vanilla js/gulp example:

var mergeStream = require('merge-stream');

function appTemplates() {
  return gulp
    .src('...')
    .pipe(p.angularTemplatecache({
      module: 'app.templates',
      standalone: true
    }));
}

function build() {
  var templates = appTemplates();
  var scripts = gulp.src('your/scripts/**/*.js');

  return mergeStream(templates, scripts)
    .pipe(concat('app.js'))
    .pipe(gulp.dest('build'));
}

gulp.task('build', build);

This way the compiled templates.js file will never touch disk, yet you can include it in your build task or whatever.

olsonpm commented 9 years ago

Hey - thanks much for the response. I'll give it a go tomorrow and let you know my results.

miickel commented 9 years ago

Ok, to close this now?

olsonpm commented 9 years ago

Yes go ahead - sorry I'll post another day with my results.

On Thu, Dec 11, 2014 at 9:02 AM, Mickel notifications@github.com wrote:

Ok, to close this now?

— Reply to this email directly or view it on GitHub https://github.com/miickel/gulp-angular-templatecache/issues/54#issuecomment-66651618 .

se-panfilov commented 9 years ago

It works. I think you may add this to the readme