Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating to Grunt/Bower from ASP.NET MVC bundling?

With ASP.NET 5, I am moving from ASP.NET MVC's bundling system to a Bower/Grunt workflow for my client-side package management and bundling/minification. I'm trying to figure out how to closely replicate the MVC bundling functionality.

With MVC bundling, I manually created all of my bundles and then call out to a helper method such as: @Styles.Render("~/bundles/styles/site"). In development I get separate link element for each CSS file in the bundle and in production I get a single combined and minified CSS file.

I have successfully set up Grunt with Bower to pull down packages and copy them into the appropriate final destination, but there's no differentiation between development and production. What's the closest functionality to my existing MVC bundling workflow?

like image 401
Brian Vallelunga Avatar asked Mar 16 '15 13:03

Brian Vallelunga


2 Answers

This article below explain a very nice way to have both (Bower and .NET Bundle Config) playing nicely together...

http://robertnoack.com/x86/2014/07/asp-net-mvc-using-bowergruntwiredep-to-inject-javascript-dependencies-into-bundleconfig-cs/

The key info, is to use a Grunt Task (wiredep) to target the BundleConfig.cs file so you could still use bower to manage your dependencies and still use BundleConfig to let .NET minify your stuff for you.

like image 152
ThiagoPXP Avatar answered Oct 30 '22 05:10

ThiagoPXP


After a day of pain, I have got grunt basically behaving in the same manner as asp.net minification with debug & release builds.

I have put together a git repo so you can just pull all the relevant files and mod as required.

https://github.com/glaidler/grunt-equivalent-asp.net-minification

like image 22
Gumzle Avatar answered Oct 30 '22 05:10

Gumzle