Gulp injection missing files

197 views Asked by At

I'm trying to use gulp-inject but something is not syncing up properly. I think it has to do with my cleaning task.

gulp.task("clean", function () {
    return gulp.src([
        "tmp/client/**/*",
        "wwwroot/**/*.css",
        "wwwroot/**/*.js"
    ], { read: false })
        .pipe(plumber())
        .pipe(clean());
});

This runs before my compile tasks, such as:

gulp.task("dev:tsc", ["clean"], function () {
    return tsResult.js
        .pipe(sourceMaps.write("."))
        .pipe(gulp.dest("wwwroot/js"));
});

Then all my compile steps run before a build task:

function injectTask(assets) {
    var layout = gulp.src("Views/Shared/_Layout.cshtml");
    var sources = gulp.src(assets, { read: false });
    return layout.pipe(inject(sources, {
        ignorePath: "wwwroot",
        addPrefix: "~",
        addRootSlash: false
    })).pipe(gulp.dest("Views/Shared"));
}

gulp.task("dev:build", ["dev:tsc", "...other tasks..."], function () {
    var vendorSources = vendorConfig.map(function (vendor) {
        return ["wwwroot/js", vendor.srcFile].join("/");
    });
    return injectTask(vendorSources.concat([
        "wwwroot/css/*.css",
        "wwwroot/js/*.js"
    ]));
});

Sometimes all my files get injected, sometimes some are missing. Sometimes I get an error about a file missing. I suspect I'm missing some step to correctly declare dependencies on the streams and prevent them from overlapping, I just can't see what it is. The complete gulpfile is here. Any ideas?

0

There are 0 answers