Running an ASP.NET MVC 4 app in release mode does not bundle and minifiy the js files

后端 未结 4 1302
死守一世寂寞
死守一世寂寞 2021-01-08 00:50

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 fe

4条回答
  •  無奈伤痛
    2021-01-08 01:13

    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)

提交回复
热议问题