When I run my ASP.NET MVC 4 app in release mode, the bundles are still outputting the unminified and separate js files, instead of bundling and minifying it into fewer bundled JavaScript files.
Any ideas?
FYI, release config:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Click on wwwroot folder, select the css file you want minified, then right click and choose bundler & minifier. Then from popup minify file. It will be the same file name with the minified version.
To enable bundling and minification, set the debug value to "false". You can override the Web. config setting with the EnableOptimizations property on the BundleTable class. The following code enables bundling and minification and overrides any setting in the Web.
Both bundling and minification are the two separate techniques to reduce the load time. The bundling reduces the number of requests to the Server, while the minification reduces the size of the requested assets.
In this article, we will add bundling in our existing web application developed in . NET CORE MVC. Firstly you have to add Bundler and Minifier extension in your project as show below by clicking on the extension menu. After adding an extension please restart the Visual Studio so that the extension will load.
Thanks to aleyush's comment that Web.release.config
is only used during publishing the app, and not when running it locally, I was able to fix it by adding the following lines to the BundleConfig.cs
file:
#if !DEBUG
BundleTable.EnableOptimizations = true;
#endif
Since Debug mode will define the DEBUG
constant, and during Release mode it is not defined, this line will only execute during Release mode. (you can test it by setting a breakpoint)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With