ligershark / WebOptimizer

A bundler and minifier for ASP.NET Core
Apache License 2.0
753 stars 113 forks source link

[Question] How to handle css isolation #233

Open lonix1 opened 2 years ago

lonix1 commented 2 years ago

I don't know if this is possible, or a bug.

I'm using RazorPages. The css isolation feature allows any razor page to have an associated css file, e.g. Products.cshtml and Products.cshtml.css.

The runtime automatically bundles all such css files into ~/www/ProjectName.styles.css. And in production there is ~/www/ProjectName.styles.min.css.

The layout page should have this: <link rel="stylesheet" href="~/ProjectName.styles.css" asp-append-version="true" />

All the above is from the official dotnet new templates.

But when running, the logs show:

An unhandled exception has occurred while executing the request. System.IO.FileNotFoundException: Could not find file '/home/username/ProjectName/wwwroot/ProjectName.styles.css'. File name: '/home/username/ProjectName/wwwroot/ProjectName.styles.css'

It cannot find the file because it's dynamically created - it doesn't even exist on disk.

How do I deal with this?