Bundling and Minification in MVC 6 - bundling-and-minification

It looks like Bundling and Minification are no longer built into MVC 6 since there is no more App_Start and Bundle.Config.
Is this going to be the case after final release?
I'm guessing Grunt should be used since that seems to be baked into Visual Studio 2015.
UPDATE: It looks like Microsoft has switched to Gulp instead of Grunt in RC1.

Bundler & Minifier Extension
The default ASP.NET Core MVC 6 project template uses a Bundler & Minifier extension. The default template used to use Gulp which was far more powerful but it was deemed too complex for newbie developers who wanted something simple. You can read more about the switch away from Gulp and the reasoning here or read the documentation for the Bundler & Minifier extension here.
WebPack, Gulp, Grunt, Brocoli, etc.
A much nicer and far more powerful method is to use Gulp, or any other task runner (There are others named Grunt, Brocoli etc. Gulp is apparently nicer to work with and newer than Grunt but also more popular than Brocoli). You can use the ASP.NET MVC Boilerplate project template to get a project with Gulp built in.
The new kid on the block is called WebPack which is according to Google about as popular as Gulp at the moment.
ASP.NET MVC 5 Bundling and Minification and Smidge
The old bundling and minification in ASP.NET MVC 5 has been dropped but there is a project on GitHub to build it for MVC 6 called Smidge.

Grunt is the recommended approach in ASP.NET 5 applications. There are no plans to build a system like the previous ASP.NET Bundling and Minification (Optimization) system.

There is an extension for VS2015 to bundle and minify files, available here:
https://visualstudiogallery.msdn.microsoft.com/9ec27da7-e24b-4d56-8064-fd7e88ac1c40
I have just used this an also created an html helper to render unbundled/unminified files in debug mode, helper available here:
https://bundlerminifierhelper.codeplex.com/
Using these you don't need to have any knowledge of gulp, task runners etc.

SquishIt provides very similar capability and API to the MVC 5 bundling. Actually it predated MVC bundling. If you want to stay in the realm of .NET, ensure you can grow into more advanced bundling scenarios that will require tighter integration with contextual route attributes, avoid wasted time debugging serverside javascript that will fail silently when you make a minor typo or misplacement requiring you to eyeball all properties, and leverage the language that we know and love, then I'd recommend SquishIt.
Javascript has its place. In my opinion this is not its place.
By using squishit you'll also decouple one less thing from the whim of the ASP.NET team.

Alternatively, if you're looking for a very simple lightweight ASP.NET Core MVC6 Gulp template (instead of default .NET Core bundles), you can look at my github project.

Related

asp.net MVC bundling with babel

Is it possible to use babel in asp.net mvc without webpack?
With the use of standard bundling available in the starter project?
It is possible of course - msbuild is powerfull build system. In cases what I know it was done through gulp (call gulp tasks on compile).
But this is wrong way because you will need to spend your time on tooling when what you need is start developing as soon as possible. So stay with open terminal window, and run npm run my-compile manually.

Adding Angular to an existing ASP.NET Web Forms project?

I'm looking for guidance on adding Angular (specifially the latest version of 4.0) to an existing ASP.NET WebForms project. I'm using Visual Studio 2017 and the .NET Framework version is 4.6.2.
I recently explored the official template project for Angular with ASP.NET Core but unfortunately since the dependencies, npm/NuGet packages came already set up for me I don't know how to add the proper, latest and greatest packages and extensions to an existing project. Not to mention that I'm using a completely different version of ASP.NET.
Any help is appreciated, Thanks!
UPDATE: I thought I should add more details. I specifically want to end up with Angular and at least webpack, Hot-module-replacement-middleware or some equivalent, BrowserLink, Karma + Jasmine and I want Angular to be using the latest TypeScript. This should make my question more specific I think.
Consider using the Angular CLI to build your Angular application and some editor such as VS Code that is friendly to the Angular CLI.
Consider not adding it to your Web Forms project and instead keeping it separate with its own functionality.
It can still communicate with whatever backend (Web API) you have.

How do you get a TFS Build Agent to Compile SASS to CSS [duplicate]

Web essentials works great when build in VS, but seems no way to build/bundle (Scss/js,Html,Sprit) when call MSBuild (like team city).
I googled lot stuffs, but only find - https://www.nuget.org/packages/Pta.Build.WebEssentialsBundleTask/ but it only support bundle, is there any other way to do that ?
finally, I found http://madskristensen.net/, Mads Kristensen split Bundler & Minifier and Web Compiler from Web Essentials 2015, and it supported integrate with MSBuild process !!!!
https://visualstudiogallery.msdn.microsoft.com/9ec27da7-e24b-4d56-8064-fd7e88ac1c40
https://visualstudiogallery.msdn.microsoft.com/3b329021-cd7a-4a01-86fc-714c2d05bb6c

What is the purpose of Antlr package in Visual Studio 2013 ASP.NET project?

The ASP.NET (web forms) project template in Visual Studio 2013 includes several packages. I'm trying to figure out which ones are essential (may need to create a separate question for this). The post at http://blogs.msdn.com/b/webdev/archive/2013/10/16/asp-net-features-in-new-project-templates-in-visual-studio-2013.aspx explains the purpose of some of them, but I cannot figure out which need Antlr serves. Can someone clarify?
It is a transitive dependency declared in the WebGrease package, where it is used for a CSS lexer and parser.
Also relevant for Visual Studio 2015 (ASP.NET MVC 5)
Bundling and minification in the ASP.Net templates is implemented in Microsoft.AspNet.Web.Optimization, which depends upon WebGrease, which itself depends upon Antlr.
So if you want to take advantage of ASP.Net template's built-in bundling and minification, you need them all.

Should I use the aspnet_compiler with a website project?

We use Nant and devenv.com to build all our assemblies including the website project. Then we would use aspnet_compiler.exe to compile the published website.
Is this the correct way to do it? Historically, we always used the aspnet_compiler with plain vanilla website folders, but I'm not sure if this is really the correct tool for publishing websites that are part of a website project. It sort of feels wrong to have to do this as a 2 stage process using 2 different tools.
Using aspnet_compiler.exe is one of many ways to publish a website:
http://forums.asp.net/t/1544792.aspx#_What_is_the1
Since a web project can be compiled using msbuild (instead of devenv.com), you can also create a custom msbuild target to publish your files:
http://www.digitallycreated.net/Blog/59/locally-publishing-a-vs2010-asp.net-web-application-using-msbuild
In this way, you can combine the compiling and publishing of the web site in one step.

Resources