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

后端 未结 4 1310
死守一世寂寞
死守一世寂寞 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:18

    My bundle was too big. I had to break it down into smaller parts and it worked fine. Maybe some variable conflicted after minification.

    Put this line at end of your bundleconfig only for test...

    BundleTable.EnableOptimizations = true;
    

    If you open the minified file, you will see something like this.

        /* Minification failed. Returning unminified contents.
        (5079,1-2): run-time warning JS1195: Expected expression: .
        (5080,18-19): run-time warning JS1004: Expected ';': :
        (5084,18-19): run-time warning JS1004: Expected ';': :
        (5091,18-19): run-time warning JS1004: Expected ';': :
        (5095,20-21): run-time warning JS1197: Too many errors. The file might not be a JavaScript file: ;
    .....
    

    Breaking down you bundle, you can isolate the issue.

    Hope this may help someone.

提交回复
热议问题