您好我正在尝试修复在我的Gulp任务中编译的js文件的顺序。
我需要的订单:
'/_sources/js/libs/*.js'
'/_sources/js/plugins/*.js'
'/_sources/js/custom/*.js'
'/_components/*.js'
问题是自定义文件夹包含自定义粒子JS 脚本,而 main particlesJS 脚本位于plugins文件夹中。因此,如果自定义脚本最终位于已编译的js文件中的 main particlesJS 之上,则一切都会中断。
我尝试使用 gulp-order 和event-stream
重新排序,但.order似乎无法正常工作,仍然以错误的顺序编译:< / p>
function compile_js(minify, folder) {
var jsLibs = gulp.src(folder+'/_sources/js/libs/*.js');
var jsPlugins = gulp.src(folder+'/_sources/js/plugins/*.js');
var jsCustom = gulp.src(folder+'/_sources/js/custom/*.js');
var jsComponents = gulp.src(folder+'/_components/*.js');
return es.merge(jsLibs, jsPlugins, jsComponents, jsCustom)
.pipe(order([
folder+'/_sources/js/libs/*.js',
folder+'/_sources/js/plugins/*.js',
folder+'/_sources/js/custom/*.js',
folder+'/_components/*.js'
]))
.pipe(concat('bitage_scripts.js'))
.pipe(gulpif(minify, uglify()))
.pipe(gulp.dest(folder+'/_assets/js'));
};
接下来我尝试了 streamqueue :
function compile_js(minify, folder) {
var jsLibs = gulp.src(folder+'/_sources/js/libs/*.js');
var jsPlugins = gulp.src(folder+'/_sources/js/plugins/*.js');
var jsCustom = gulp.src(folder+'/_sources/js/custom/*.js');
var jsComponents = gulp.src(folder+'/_components/*.js');
return streamqueue({ objectMode: true },
gulp.src([
jsLibs,
jsPlugins,
jsCustom]),
gulp.src([jsComponents]).pipe(sass())
)
.pipe(concat('bitage_scripts.js'))
.pipe(gulpif(minify, uglify()))
.pipe(gulp.dest(folder+'/_assets/js'));
};
引发了这个错误:Error: Invalid glob argument: [object Object],[object Object],[object Object]
任务:
// Development task
gulp.task('devsite', function () {
minify = false;
return compile_js(minify, 'public');
});
有任何想法/建议吗?
答案 0 :(得分:2)
试试这个。
function compile_js(minify, folder) {
var jsLibs = gulp.src(folder+'/_sources/js/libs/*.js');
var jsPlugins = gulp.src(folder+'/_sources/js/plugins/*.js');
var jsCustom = gulp.src(folder+'/_sources/js/custom/*.js');
var jsComponents = gulp.src(folder+'/_components/*.js');
return streamqueue({ objectMode: true },
jsLibs,
jsPlugins,
jsCustom,
jsComponents
)
.pipe(concat('bitage_scripts.js'))
.pipe(gulpif(minify, uglify()))
.pipe(gulp.dest(folder+'/_assets/js'));
};
gulp.src(gulp.src('folder+'/_source/something'))
没有意义。