Reputation: 35861
I have the following bundle in my RegisterBundles()
method of the BundleConfig.cs
file:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery.unobtrusive-ajax.js",
"~/Scripts/jquery.serializeObject.js",
// https://raw.githubusercontent.com/mathiasbynens/he/master/he.js
"~/Scripts/he.js"));
They all have minified versions (.min.js
) in the Scripts
folder, so no minification needs to occur. As they are vendor libraries, no transpiling is required either. They just need to be added as one bundle, using their existing minified versions.
I've been looking at this to help me. Here's what I've got thus far:
gulp.task('scripts', function() {
return gulp.src
([
"Scripts/jquery-{version}.min.js", // --> what glob do you use for {version}?
"Scripts/jquery.unobtrusive-ajax.min.js",
"Scripts/jquery.serializeObject.min.js",
"Scripts/he.min.js"
])
.pipe(concat('bundle.js'))
.pipe(gulp.dest('src/js/'));
});
Notice the line with {version}
. Using BundleConfig.cs
, it's currently grabbing jquery-3.2.1.min.js, and any future ones I put there. Is there an equivalent way in gulp to do this using a glob pattern?
Also, is the above the correct way to bundle vendor libraries in gulp?
Thanks.
Upvotes: 1
Views: 811
Reputation: 144
Just use a *
(star) character.
gulp.task('scripts', function() {
return gulp.src([
"Scripts/jquery-*.min.js", // --> what glob do you use for {version}?
"Scripts/jquery.unobtrusive-ajax.min.js",
"Scripts/jquery.serializeObject.min.js",
"Scripts/he.min.js"
])
.pipe(concat('bundle.js'))
.pipe(gulp.dest('src/js/'));
});
Then it will use all your jQuery files no matter which version they have.
Upvotes: 1