与合并流一饮而尽阶节点模块 [英] gulp-order node module with merged streams
问题描述
我使用的是一饮而尽阶模块与事件流模块,并吞掉,CONCAT一起javascript文件连接成一个单一的文件DEST。该一饮而尽阶插件已经在我就想来连接在不同的顺序从流文件的其他项目工作对我来说太棒了。出于某种原因,在这个项目它不能正常工作,并在公共/角/ config目录中的文件被分散我指定最后的公共/ JS目录来连接这些文件之中。我想,这可能是与规定,即乘源。角和js目录。我试过,没有运气合并与事件流模块的数据流,而当我第一次开始我通过传递一个数组到gulp.src函数指定的多个源
gulp.src(['./公共/角/ ** / *。JS','./public/js/*.js'])
下面是code我现在使用。管道和串联都工作正常,但订单不按说明:
VAR一饮而尽=要求('吞掉');
VAR CONCAT =要求('一饮而尽-CONCAT');
VAR通知=要求('一饮而尽-通知);
VAR handleErrors =要求('../ UTIL / handleErrors');
VAR jshint =要求('一饮而尽-jshint');
VAR ngmin =要求('一饮而尽-ngmin');
VAR为了=要求('一饮而尽,令);
VAR ES =要求('事件流');功能getStream(streamPath){
返回gulp.src(streamPath);
};gulp.task('脚本',函数(){
返回es.merge(getStream('./公共/角/ ** / *。JS'),getStream('./公共/ JS / *。JS'))
.pipe(顺序([
./public/angular/config/*.js',
./public/angular/services/**/*.js',
./public/angular/modules/**/*.js',
./public/angular/primitives/**/*.js',
./public/js/**/*.js
]))
.pipe(CONCAT('app.js'))
.pipe(gulp.dest('./公共/建设/ JS'))
。对('错误',handleErrors);
});
我有同样的问题,我用吞掉打印
来看到我流的文件名,但他们是正确的。我发现我需要的基
选项添加到吞掉序
,那么所有运行良好。
gulp.src(['MYFILES / *','myOtherFiles / *'])
.pipe(顺序([
myOtherFiles / lib1.js',
MYFILES / lib2.js
] {基地:''});
有用的文章:的http://martinwolf.org/2014/08/12/force-a-concatenation-order-with-gulp-js/
更新:新链接博客文章:的 https://martinwolf.org/blog/2014/08/force-a-concatenation-order-with-gulp-js
I'm using the gulp-order module along with the event-streams module and gulp-concat to concatenate javascript files into a single dest file. The gulp-order plugin has worked great for me in other projects where I wanted to concatenate files from the stream in a distinct order. For some reason in this project it is not working properly, and the files in the public/angular/config directory are dispersed amongst the files I specify to concatenate last in the public/js directory. I think this may have something to do with specifying multiply sources ie. the angular and js directories. I tried merging the streams with the event-streams module with no luck, whereas when I first began I specified the multiple sources by passing an array to the gulp.src function
gulp.src(['./public/angular/**/*.js', './public/js/*.js'])
Below is the code I'm using now. The piping and concatenation are working fine but the order is not following the specification:
var gulp = require('gulp');
var concat = require('gulp-concat');
var notify = require('gulp-notify');
var handleErrors = require('../util/handleErrors');
var jshint = require('gulp-jshint');
var ngmin = require('gulp-ngmin');
var order = require('gulp-order');
var es = require('event-stream');
function getStream(streamPath) {
return gulp.src(streamPath);
};
gulp.task('scripts', function() {
return es.merge(getStream('./public/angular/**/*.js'),getStream('./public/js/*.js'))
.pipe(order([
'./public/angular/config/*.js',
'./public/angular/services/**/*.js',
'./public/angular/modules/**/*.js',
'./public/angular/primitives/**/*.js',
'./public/js/**/*.js'
]))
.pipe(concat('app.js'))
.pipe(gulp.dest('./public/build/js'))
.on('error', handleErrors);
});
I had this same issue, and I used gulp-print
to see the filenames in my stream, but they were correct. I found out that I needed to add the base
option to gulp-order
, then all worked well.
gulp.src(['myFiles/*', 'myOtherFiles/*'])
.pipe(order([
'myOtherFiles/lib1.js',
'myFiles/lib2.js'
], {base: '.'});
Helpful article: http://martinwolf.org/2014/08/12/force-a-concatenation-order-with-gulp-js/
UPDATE: new link to blog article: https://martinwolf.org/blog/2014/08/force-a-concatenation-order-with-gulp-js
这篇关于与合并流一饮而尽阶节点模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!