Created
April 26, 2020 13:50
-
-
Save LeoEatle/d2531225d4f60cb9404d7195966ba4b3 to your computer and use it in GitHub Desktop.
Gulp forking a stream (e.g. send different files to different dests)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task("ts", function() { | |
// These would be the names of two source files for example | |
tsRootFiles = ["rab", "buildRab"]; | |
tsRootFiles.forEach(tsFile => { | |
let stream = gulp | |
.src(`ts/${tsFile}.ts`) | |
.pipe(sourcemaps.init()) | |
.pipe( | |
ts({ | |
noImplicitAny: true, | |
outFile: `${tsFile}.js`, | |
allowJs: true, | |
lib: ["ES2016"], | |
target: "ES5", | |
}) | |
) | |
.pipe(sourcemaps.write()); | |
// Now send them different places (here based on name but obvs. whatever logic suits) | |
if (tsFile === "rab") { | |
stream = stream.pipe(gulp.dest("_build/js")); | |
} else { | |
stream = stream.pipe(gulp.dest("banners/js")); | |
} | |
return stream; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment