In VS 2019 when I try to Publish
to a folder Gulp
fails with ReferenceError: merge is not defined
.
gulpfile.js
/// <binding AfterBuild='default' />
var gulp = require('gulp');
var uglify = require("gulp-uglify");
var concat = require("gulp-concat");
gulp.task('minify', function () {
return gulp.src("wwwroot/js/**/*.js")
.pipe(uglify())
.pipe(concat("dutchtreat.min.js"))
.pipe(gulp.dest("wwwroot/dist"));
});
var nodeModules = {
"bootstrap": { "dist/**/*": "" },
"font-awesome": { "**/*": "" },
"jquery": { "dist/*": "" },
"jquery-validation": { "dist/*": "" },
"jquery-validation-unobstrusive": { "dist/*": "" } };
gulp.task("node_modules", function () {
let streams = [];
for (var module in nodeModules) {
console.log("Prepping Scripts for: " + module);
for (var itemProp in nodeModules[module]) {
streams.push(gulp.src("node_modules/" + module + "/" + itemProp)
.pipe(gulp.dest("wwwroot/lib" + module + "/" + nodeModules[module][itemProp])));
}
}
return merge(streams);
});
gulp.task('default', gulp.series("node_modules", "minify"));
package.json "devDependencies"
"gulp": "4.0.2",
"gulp-uglify": "3.0.2",
"gulp-concat": "2.6.1",
"merge-stream": "2.0.0",
"merge": "1.2.1"
All 5 files are loaded in the Dependencies | npm folder.
Why can it not find merge
? Is this syntax correct for Gulp 4
?
You need to require merge to use it like you have with everything else.
var merge = require(“merge-stream”);
I think I usually use gulp-merge but I believe merge-stream will work just as well.