Last active
December 31, 2015 21:29
-
-
Save kimjoar/8046855 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var concat = require('gulp-concat'); | |
var header = require('gulp-header'); | |
var footer = require('gulp-footer'); | |
var templateCache = require('./template-cache'); | |
var templateCacheWrapper = require('./template-cache-wrapper'); | |
gulp.task('default', function() { | |
var templateHeader = "{{ angular }}.module('{{ module }}'{{ standalone }}).run(['$templateCache', function($templateCache) {\n"; | |
var templateFooter = "}]);\n" | |
gulp.src('./templates/*.html') | |
// this is my gulp plugin, but it won't work without a header and footer in the concat'ed file | |
.pipe(templateCache()) | |
.pipe(concat("template.js")) | |
.pipe(header(templateHeader, { | |
angular: 'angular', | |
module: 'app', | |
standalone: ', []' | |
})) | |
.pipe(footer(templateFooter)) | |
.pipe(gulp.dest('./dist/')) | |
}); | |
// for ease of use, I want to create a wrapper | |
gulp.task('default', function() { | |
gulp.src('./templates/*.html') | |
.pipe(templateCacheWrapper()) | |
.pipe(gulp.dest('./dist/')) | |
}); |
The stream you return from your plugin function can be piped to other streams.
Swap
return yourPluginStream
for
return yourPluginStream.pipe(header()).pipe(footer())
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(yeah, as you probably can tell, I'm not used to working with streams yet)