Closed alexanderby closed 7 years ago
commonStream
should not be multiple consumed
Please try:
//...
const getCommonStream = () => {
return gulp.src(`./common.less`)
.pipe(less())
.pipe(rename(`common.css`))
.pipe(gulp.dest('./result'));
}
return merge(getCommonStream(), ...themes.map((theme) => {
const streams = files.map((file) => getThemedStream(theme, file));
streams.push(getCommonStream());
return getConcatStream(theme, streams);
}));
But commonStream
will be recompiled multiple times with the same result, which is not efficient.
Is it work in my way?
Your sample works. Unfortunately I keep loosing some files in my production build (not a problem for merge-stream
). I'll try to provide you a sample to reproduce that.
I've tried to create my own stream sequencer based on merge-stream
but failed when streams participate in multiple sequences https://github.com/grncdr/merge-stream/issues/29#issuecomment-313325679
Finally I solved my problem by splitting my Gulp tasks into multiple sub-tasks and running them with run-sequence
.
I have to build multiple CSS files and create bundles of all that files with multiple themes. Some file is included in multiple bundles. But after script is run that file is missing in concatenation results. When I replace
merge2
withmerge-stream
it works, but concatenated files have random order.