gulp.src()不读书所需的JSON文件的数组值 [英] gulp.src() not reading required JSON file's array values
问题描述
我试图让 gulp.src()
流从一个数组文件,这样我就可以用大口,注入到他们写信给我的index.html文件。下面列出的是我的 gulp.config.json
文件,该文件将举行包括在我的项目中的软件包的文件路径。结果
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"
]
}
我gulpfile.js看起来像这样用于调试搜索结果
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());
});
和似乎只输出到控制台:结果吞掉调试:JS /供应商/角-UI-tour.js
结果
结果
这是除非我切换 paths.vendorjs
到 paths.js
像这样: gulp.src (paths.js).pipe(调试())
,然后我得到的输出为JS数组中的每个文件
结果
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?
推荐答案
最有可能的,除了显示一个所有文件的路径是不正确的,使他们不进入管道。您可以使用像一饮而尽,预计文件,以检查是否所有文件已进入到管道。
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.
这篇关于gulp.src()不读书所需的JSON文件的数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!