WebOptimizer AddLessBundle works in Dev, but not when I publish to Azure

675 views Asked by At

When I publish my core3.1 website to Azure the path to the css files returns a 404 www.mysite.com/css/StyleBundle.css

Here is my config.

app.UseWebOptimizer();
app.UseStaticFiles();

var cssSettings = new CssSettings();
var jsSettings = new CodeSettings();

if (_Environment.IsDevelopment())
{
    cssSettings = CssSettings.Pretty();
    jsSettings = CodeSettings.Pretty();
}

services.AddWebOptimizer(options =>
{
    //css/Less bundles
    options.AddLessBundle("/css/BootstrapBundle.css",
        "Styles/bootstrapmac.less")
        .MinifyCss(cssSettings)
        .UseContentRoot();
});

But when I add this AddCssBundle code, it does work in Azure.

       options.AddCssBundle("/css/ab.css",
            "Styles/a.css",
            "Styles/b.css")
        .UseContentRoot();
1

There are 1 answers

1
Tim Van Every On

"www.mysite.com/**css/StyleBundle.css" does not match your bundle name in:

options.AddLessBundle(**"/css/BootstrapBundle.css"**,
        "Styles/bootstrapmac.less")
        .MinifyCss(cssSettings)
        .UseContentRoot();

Change to: "www.mysite.com/**css/StyleBundle.css"

options.AddLessBundle(**"/css/StyleBundle.css"**,
        "Styles/bootstrapmac.less")
        .MinifyCss(cssSettings)
        .UseContentRoot();