Skip to content

Developer Notes

Martin Konopka edited this page Apr 5, 2018 · 1 revision

Bower and Grunt instead of NuGet

To include JavaScript libraries, we use Bower instead of NuGet because of multiple reasons:

  • most of the JavaScript libraries are not present on NuGet;
  • even if the libraries are present, most of the time they are outdated;
  • download libraries were stored in the project's source code repository.

Bundling bower components

New ASP.NET Core project templates use Bower from scratch. But the UXR Web is still an ASP.NET MVC 5 app. ASP.NET MVC 5 projects originally use Bundles specified in BundleConfig.cs file which are then referenced in Razor views.

Grunt replaces this bundling process. To retain referencing of bundles in Razor views, we need to sync BundlesConfig with Grunt bundling output. Instead of doing this manually, we use an approach described in the following blog posts and GitHub repository by Jon Smith:

Following these posts and example project, these changes were made in the UXR project:

  • added reference to the Bundler4Bower package from NuGet,
  • added BowerBundles.json which specifies bundles.
  • added BowerBundlerHelper that is used in the Razor views.

Why Bundler4Bower?

Bundler4Bower may be removed if it brings any problems. Here are resources which do not use Bundler4Bower:

Why not Gulp, or other package manager?

Yes, Gulp is another option instead of Grunt. Gulp is used in ASP.NET Core projects and may replace Grunt.