.CSS / .SCSS extension conflict from the link tag helper when EnableTagHelperBundling = false and using AddScssBundle() #70
Description
Background
We're in the process of replacing the Bundle & Minify plug-in with this library since it gives us better bundle flexibility in addition to compiling .sass files. During local development, we want to disable the EnableTagHelperBundling so we can get each file output for debugging specifically for our .js bundles.
Setup
- Visual Studio 2022 - 17.8.3
- .NET - 8.0 (My application however confirmed on the sample project running .NET Core 3.0)
- LigerShark.WebOptimizer.Core - 3.0.396
- LigerShark.WebOptimizer.Sass - 3.0.102
Test Setup
- Upgrade the references in WebOptimizer.Sass to LigerShark.WebOptimizer.Core (3.0.396)
- Open the sample project in this repository and change the Startup.cs from this:
services.AddWebOptimizer(pipeline =>
{
// Creates a Sass bundle. Globbing patterns supported.
pipeline.AddScssBundle("/css/bundle.css", "scss/*.scss");
// This will compile any Sass file that isn't part of any bundle
pipeline.CompileScssFiles();
});
to this
services.AddWebOptimizer(pipeline =>
{
// Creates a Sass bundle. Globbing patterns supported.
pipeline.AddScssBundle("/css/bundle.css", "scss/*.scss");
// This will compile any Sass file that isn't part of any bundle
pipeline.CompileScssFiles();
}, option =>
{
option.EnableTagHelperBundling = false;
});
###Expected Results
Since we want each file to render instead of the single bundle, we should expect to see
<link href="scss/a.scss?v=Hash" rel="stylesheet" />
<link href="scss/b.scss?v=Hash" rel="stylesheet" />
This works due to the request to simply render the individual files that make up this bundle and because this library will render a SCSS file as a minified CSS file upon request.
Actual Results
<link href="scss/a.css" rel="stylesheet" />
<link href="scss/b.css" rel="stylesheet" />
We can see that the extension has been changed from the link tag helper from .scss
to .css
resulting in a 404 error on the server and no styles being rendered. Also note the lack of the ?v=Hash on these elements. The same issue affects the index page which directly references the /scss/a.scss
file here when the EnableTagHelperBundling=false
is set.
Potential Solution
I cloned this repository as well as the WebOptimizer.Core
repository. Next, I removed the NuGet reference from this project and referenced the local copy of the Core project directly. When I comment out this line of code the project returns the expected values in both the "un-budling" (render each file individually from a bundle reference) scenario on the Bundle.cshtml page and the direct reference on the Index.cshtml page.
I am not familiar enough with this project to know what potential impacts removing that line of code would have, but it does seem to conflict with this library and un-bundling .scss files