gulp.src() not reading required JSON file's array values

左心房为你撑大大i 提交于 2019-12-13 18:42:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!