8

I added the bundle in BundleConfig.cs as shown below:

 bundles.Add(new ScriptBundle("~/bundles/angular").Include("~/Scripts/angular.min*"));

In the _Layout.cshtml I have the following:

<body>
    @RenderBody()

    @Scripts.Render("~/bundles/jquery")

    @Scripts.Render("~/bundles/angular")

    @RenderSection("scripts", required: false)
</body>
</html>

In the network traffic it does not show the angular file.

3 Answers 3

20

Bundling in ASP.NET MVC is quite clever in that it understands *.min and when to use or no to use it. So if you do this in your bundle:

bundles.Add(new ScriptBundle("~/bundles/angular").Include("~/Scripts/angular.js"));

In debug-mode, it will send a request for "/scripts/angular.js" and in release-mode it will send a request to "/scripts/angular.min.js"

In order to benefit from this, you should put both the original and the minified file in your scripts folder. That way, when you're debugging you have full access to the uncompressed source and in your production environment, the optimized file will be loaded

Sign up to request clarification or add additional context in comments.

1 Comment

Just remember, if the .min does not exist to the unmifined file, the built in mifier will do it for you based on the unmified file. There is really no reason to keep minified files next to unmified ones as sometimes this causes a great deal of confusion if you update the unminified file to newer versions but the the minified one is still the old one.
0

you have given incorrect file name

~/Scripts/angular.min*

instead it should be

~/Scripts/angular.js

.min would automatically be added in the production mode\

Bundler not including .min files

3 Comments

The file name is angular.min.js
download both the files compressed and non-compressed and put them in the folder
thats the way it will work.. or just rename the file from angular.min.js to angular.js
0

in my case the problem was with Global.asax.cs

you need to have

BundleConfig.RegisterBundles(BundleTable.Bundles);

in your Application_Start()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.