简体   繁体   中英

Getting Error: Invalid output folder when using gulp-angular-templatecache to create a combined HTML template file

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?

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

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

~ @stevelacy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM