I'm trying out the new ASP.NET 5 with MVC 6, and I'm using bower to manage all my client-side dependencies. Everything is working fine.
But I have a question: When I add a dependency (let's say jQuery). It adds both the /dist
and /src
along with bower configuration files to the /lib
folder of wwwroot
. How do I make it include just the compiled source for usage? (So I can reference it in my pages via /lib/jquery/jquery.js
?
I have recently been playing in this space and following is something that I have tried:
.bowerrrc
file to enable installing in the defaultbower_components
folder under the project folder rather than underwwwroor\lib
as anything underwwwroot
tends to get published."main-bower-files": "2.9.0"
topackage.json
. This package gets all the files mentioned in themain
property of each installed package'sbower.json
files.Created a gulp task using the above package
gulp.task('copyMainFiles', function () { return gulp.src(mainBowerFiles(), { base: 'bower_components' }) .pipe(gulp.dest('wwwroot/lib')); });
Added a
postrestore
step to your application'sproject.json
file"scripts": { "postrestore": "gulp copyMainFiles", "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ] }
Updated my application's
bower.json
to copy files which are not listed inmain
(like some packages do not have min files as main files..ex: jQuery). The following settings are read bymain-bower-files
:"overrides": { "jquery": { "main": [ "dist/jquery.js", "dist/jquery.min.js" ] }, "hammer.js": { "main": [ "hammer.js", "hammer.min.js" ] }, "bootstrap": { "main": [ "./dist/js/bootstrap.js", "./dist/js/bootstrap.min.js", "./dist/css/bootstrap.css", "./dist/css/bootstrap.min.css" ] } }
jquery-validation
package to use1.14.0
instead of1.11.1
as the previous version does notdist
folder and indeed no bower.json...