Minification failed. Returning unminified contents

前端 未结 12 2118
清酒与你
清酒与你 2020-12-24 11:24

I have made my first website using MVC 5 which works fine on my local machine but when I publish it to the server some of the CSS is not minifying correctly.



        
12条回答
  •  半阙折子戏
    2020-12-24 12:05

    I resolved the problem bundling bootstrap.css by doing 2 things:

    1. Include the bootstrap.css first in the bundle. The code sample in the question already does this, but I was not.
    2. Add the official minified version (bootstrap.min.css) to the project in the same directory as the unminified version. This prompts the bundler to use the existing minified file instead of trying (and failing) to minify bootstrap.css itself. See the green arrow in the screenshot below.

    Note that if you are using a specific theme, substitute bootstrap.css and bootstrap.min.css with the files provided by the theme. Here's the working code from my project that uses the spacelab theme:

                bundles.Add(new StyleBundle(GetStyleBundlePath("bootstrap")).Include(
                "~/Content/3rdParty/bootstrap.spacelab.css",
                "~/Content/3rdParty/bootstrap-datepicker.css",
                "~/Content/3rdParty/bootstrap-multiselect.css"));
    

    enter image description here

提交回复
热议问题