1

I'm trying to get gulp.src() to stream files from an array, so I can use gulp-inject to write them to my index.html file. Listed below is my gulp.config.json file which will hold the file paths of the packages included in my project.

{
    "vendorjs": [
        "jquery/dist/jquery.min.js",
        "angular/angular.js",
        "ng-token-auth/dist/ng-token-auth.js",
        "angular-bootstrap/ui-bootstrap-tpls.min.js",
        "ngInfiniteScroll/build/ng-infinite-scroll.min.js",
        "js/vendor/angular-ui-tour.js",
        "spin.js/spin.js",
        "angular-spinner/angular-spinner.min.js",
        "angular-scroll/angular-scroll.js"
    ],
    "js": [
        "js/app.js",
        "js/directives.js",
        "js/services.js",
        "js/filters.js"
    ]
}

my gulpfile.js looks like this for debugging purposes

Gulpfile.js

var gulp = require('gulp'),
    inject = require('gulp-inject'),
    paths = require('./gulp.config.json'),
    debug = require('gulp-debug');

gulp.task('default', function() {
    gulp.src(paths.vendorjs).pipe(debug());
});

and it only seems to output to the console:
gulp-debug: js/vendor/angular-ui-tour.js

that is unless I switch paths.vendorjs to paths.js like so: gulp.src(paths.js).pipe(debug()) and then I get output for every file in the js array

gulp-debug: js/app.js
gulp-debug: js/directives.js
gulp-debug: js/services.js
gulp-debug: js/filters.js

Could someone please clarify why this is happening?

1 Answer 1

1

Most likely the paths for all the files except for the one displayed are not correct so they don't enter into the pipe. You can use something like gulp-expect-file to check if all the files have entered to the pipe.

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

4 Comments

So the paths in the array actually have to match a file in the project? I was under the impression it would be a 'path in path out' situation since I'm not actually doing anything with the paths aside from using their names.
Yes, those files have to exist at that location, gulp will take those files and run them through a series of transformations and then write them with gulp.dest. If the file doesn't exist nothing is happening.
Is there a way to get gulp to ignore finding them and just use the names, or do I have to add, ../../components/bower_components to all of my file paths?
it does ignore them, there is nothing happening to them. The gulp.src is meant to take a list of files, it can't take a list of strings. But what are you trying to accomplish? What would be your main goal with gulp?

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.