4

I'm using Gulp for our build process. One of the major tasks it needs to accomplish is combining all our .html template partials from all the module folders into 1 .js templateCache file. Which creates just 1 download for the user for all the HTML files.

gulp-angular-templatecache


Current Gulp require and config setup:

var gulp          = require('gulp'),
    gutil         = require('gulp-util'),
    gulpif        = require('gulp-if'),
    uglify        = require('gulp-uglify'),
    concat        = require('gulp-concat'),
    sass          = require('gulp-ruby-sass'),
    streamqueue   = require('streamqueue'),
    sourcemaps    = require('gulp-sourcemaps'),
    templateCache = require('gulp-angular-templatecache'),
    runSequence   = require('run-sequence'),
    del           = require('del'),
    es            = require('event-stream');

var config = {
    srcPartials:[
        'app/beta/*', 
        'app/header/**/*',
        'app/help/*',
        'app/login/*',
        'app/notificaitons/*',
        'app/panels/**/*',
        'app/popovers/**/*',
        'app/popovers/*',
        'app/user/*',
        'app/dashboard.html'
    ],
    destPartials: [
        'app/templates/'
    ]
};

The html-templates Gulp task:

/** HTML Template caching */
/** ------------------------------------------------------------------------- */
gulp.task('html-templates', function() {
    return gulp.src(config.srcPartials)
    .pipe(templateCache())
    .pipe(gulp.dest(config.destPartials));
});

^ so as you can see above, I'm aiming to take all the .html files from all the folders listed in srcPartials and run templateCache on them and export out to the dest in destPartials.

However currently getting this error:

Error: Invalid output folder at Gulp.dest

At first I thought that this task didn't automatically create the folder, so I went ahead and created the app/templates folder, but still getting this error :( any thoughts?

1 Answer 1

4

Ah just stumbled onto the answer: The output folder is a string, not an array.

https://github.com/gulpjs/gulp/issues/496

~ @stevelacy

Sign up to request clarification or add additional context in comments.

1 Comment

Now on to the next step: Getting the Directives to use the new template.js file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.