WebOptimizer icon indicating copy to clipboard operation
WebOptimizer copied to clipboard

NullReference Exception when using inline on bundle

Open plecos opened this issue 3 years ago • 0 comments

I get a null ref exception when I start my web site only if I specify inline on my bundles. Here is my service config:

if (WebHostEnvironment.IsDevelopment())
{
                services.AddWebOptimizer(minifyJavaScript: false, minifyCss: false);
            }
            else
            {
                // web optimizer
                services.AddWebOptimizer(pipeline => {
                    pipeline.AddCssBundle("/css/bootstrapbundle.css",
                        "/wwwroot/lib/twitter-bootstrap/css/bootstrap.css",
                        "/wwwroot/lib/font-awesome/css/all.css",
                        "/wwwroot/css/site.css")
                    .UseContentRoot();
                    pipeline.AddJavaScriptBundle("/js/bootstrapbundle.js",
                        "/wwwroot/lib/jquery/dist/jquery.js",
                        "/wwwroot/lib/popper.js/umd/popper.js",
                        "/wwwroot/lib/twitter-bootstrap/js/bootstrap.js",
                        "/wwwroot/lib/font-awesome/js/all.js",
                        "/wwwroot/lib/sweetalert2/sweetalert2.min.js",
                        "/wwwroot/js/site.js")
                    .UseContentRoot();
                });
            }

and here is the html:

<environment include="Development">
        <link rel="stylesheet" href="~/lib/twitter-bootstrap/css/bootstrap.css" />
        <link rel="stylesheet" href="~/lib/font-awesome/css/all.css" />
        <link rel="stylesheet" href="~/lib/bootstrap-daterangepicker/daterangepicker.css" />
        <link rel="stylesheet" href="~/css/site.css" />
    </environment>
    <environment exclude="Development">
        <link rel="stylesheet" href="/css/bootstrapbundle.css" inline />
    </environment>

plecos avatar Jul 26 '21 15:07 plecos