이것은 스트림에 대한 제한된 이해에서 비롯된 것으로 의심되지만 사방에 쳐다 보았지만 제대로 작동하지 않습니다. 간단히 말해 Gulp 스트림을 가져 와서 스트림의 연결된 내용을 직접 명시 적 응답에 전달하고 파일 시스템에 쓰지 않고 싶습니다. 파이프 연결 Gulp 스트림 file.contents를 서버 (connect, express 또는 http) 응답에 연결
이
내가 (잘 작동) 아이디어를 가지고하는 방법입니다app.get('*', function(req, res){
var stream = fs.createReadStream(__dirname + '/app/index.html');
stream.pipe(res);
});
을하지만 나는 꿀꺽 스트림을 사용하여 동일한 개념을 적용 할 :
app.get('/app/js/concatenated-js-files.js', function(req, res){
gulp.src('app/js/**/*.js')
.pipe(concat())
.pipe(res);
});
app.listen(5555, function() {
console.log('Listening on port 5555');
});
작동 및 수율하지 않는 브라우저에서 /app/js/concatenated-js-files.js
을 요청할 때 다음을 입력하십시오.
[gulp] Error in plugin 'gulp-concat': Missing fileName option for gulp-concat
at module.exports (/Users/lgomez/Projects/index-packager/node_modules/gulp-concat/index.js:10:24)
at Object.handle (/Users/lgomez/Projects/index-packager/index.js:83:15)
at next_layer (/Users/lgomez/Projects/index-packager/node_modules/express/lib/router/route.js:103:13)
at Route.dispatch (/Users/lgomez/Projects/index-packager/node_modules/express/lib/router/route.js:107:5)
at /Users/lgomez/Projects/index-packager/node_modules/express/lib/router/index.js:213:24
at Function.proto.process_params (/Users/lgomez/Projects/index-packager/node_modules/express/lib/router/index.js:284:12)
at next (/Users/lgomez/Projects/index-packager/node_modules/express/lib/router/index.js:207:19)
at Layer.expressInit [as handle] (/Users/lgomez/Projects/index-packager/node_modules/express/lib/middleware/init.js:23:5)
at trim_prefix (/Users/lgomez/Projects/index-packager/node_modules/express/lib/router/index.js:255:15)
at /Users/lgomez/Projects/index-packager/node_modules/express/lib/router/index.js:216:9
해당 오류는 expec입니다. 테드. gulp-concat은 (는) 파일에 출력되었습니다.
gulp-concat와 매우 유사한 gulp 플러그인을 작성하는 것을 피하고 싶습니다. 내가 포크를 잡고 그것을 제안 할 수도 있지만, 현재로서는 이것을 달성 할 수있는 또 다른 방법이 있습니까?
감사합니다.
시도해 보려면 전체 코드를 참조하십시오. 가상 파일 객체가 아닌 실제 파일의 스트림에
var express = require('express');
var gulp = require('gulp');
var concat = require('gulp-concat');
var app = express();
app.get('/app/js/concatenated-js-files.js', function(req, res){
gulp.src('app/js/**/*.js')
.pipe(concat())
.pipe(res);
});
app.listen(5555, function() {
console.log('Listening on port 5555');
});
// http://localhost:5555/app/js/concatenated-js-files.js
** 참고 : ** [이벤트 스트림] (https://github.com/dominictarr/event-stream), [bufferstreams] (https://github.com/nfroidure/BufferStreams) 및 [kat] (https://github.com/fent/node-kat)하지만 행운은 없습니다. – luisgo