I had a previously working local configuration that is not bundling even with forcing the settings.
This is happening on both JS and CSS bundling.
Example code only
private static List<string> ScriptBundleExample
{
get
{
return new List<string>()
{
"~/Assets/javascriptfile1.js",
"~/Assets/javascriptfile2.js",
};
}
}
// separate function
var bundle = new ScriptBundle("~/Bundles/javascript-example");
ScriptBundleExample.ForEach(script => {
bundle.Include(script)
}
bundles.Add(bundle);
I have appropriately added the render in my layout:
// different casing to above but never mattered
@Scripts.Render("~/bundles/javascript-example")
I have forced the setting here which should be bundling correctly:
Note: This setting overrides the debug setting within Web.config yet it still doesn't work with both overrides.
BundleTable.EnableOptimizations = true;
I have also turned off any debugging in Web.config (both in wwwroot and the project file):
<compilation debug="false" targetFramework="4.7.2" />
FWIW minifying also isn't working:
bundle.Transforms.Add(new JsMinify());
Previous related questions on SO
The OP worked on the assumption debug="true"
was the correct setting which it was not.
Bundled scripts not working MVC
This was a minification issue which is not the case here.
MVC Bundle not working with Release Configuration (Debug is False), CSS and JS not loading
I'm not getting 404 errors because the bundling isn't working but the proper files are still coming out the server as individual scripts (as if I'm always in debug mode) so the files are being included correctly.
ASP.NET MVC Bundle not rendering script files on staging server. It works on development server
This person just didn't understand the bundling and minification process.
WebGrease package exists in my solution.
Why is my CSS bundling not working with a bin deployed MVC4 app?
Same as above, the OP did not understand how these settings worked. I do not have a .js extension in my bundles.
Not in SO but this didn't work.