问题
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:
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.
来源:https://stackoverflow.com/questions/31579421/gulp-src-not-reading-required-json-files-array-values