-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embedded Content (how static assets work with multi-project scenarios) #6349
Comments
Can you share some details around what is the current idea to handle the scenario? Will the |
We've done some thinking on this, and here's an overview:
That's all there is to it. It's a minimal set of new concepts, and should work equally for Razor Components, Blazor, or any other ASP.NET Core web application that wants to consume static content from packages/projects. |
Feel free to edit the top post. Mechanically - how does this work for a nuget package. So if I'm building a library, what happens? |
I also want to see more detail about how this will work |
Thought: Take into account what the Identity UI does today for the files in https://github.com/aspnet/AspNetCore/tree/master/src/Identity/UI/src/wwwroot and that we should update Identity UI to use this new pattern once it's available. cc @javiercn @HaoK |
@Eilon Steve an I already chatted about this. We have a new plan in mind and I'm hoping we also move Identity UI to this model too. TL;DR They will end up as published content during publish and they will be served from their original locations during development. |
My way is https://github.com/SamProf/EmbeddedBlazorContent
This will produce code like this:
In action I use this method in my http://www.matblazor.com |
@javiercn
|
We will be handling the documentation piece next week, but essentially you just need to put the files from the library inside a wwwroot folder and they will get exposed under the |
@javiercn Is it expected for a class library, whose package id contains dots to have its static assets path generated without the dots? If there is a library called
then the path to the file is |
@Stamo-Gochev Yes. We do some work to sanitize the url by removing dots and lower-casing everything (to minimize differences across OSs). Is there a reason for you to want dots in the url? They can be problematic when combined with other things like redirect rules, file system providers, etc. Did you take that into account? |
The main concern is that the name of the class library consists of several words and combining them without the dots results in a long word that is harder to read. I cannot replaces the dots with dashes as it will be a breaking change. Can there be an option that can control if the dots will be stripped? |
@Stamo-Gochev We do have some guidance coming up on how to properly author razor class libraries with static web assets. I don't remember if we have a switch for it, but I'll make sure it gets included in the docs if there is one.
If we were to replace the dots with something else (like I wouldn't be too concerned about this for a few reasons.
We don't think it'll be very practical/common for people to be typing script urls by hand compared to copying them from the instructions for a specific library. |
@javiercn Yes, the class library provides instructions on how to consume its static assets, so it is a copy and paste step. The If a new class library is created now, it might not have such a problem as we are now aware of how its name will be exposed and it is up to us to decide how to name the new lib, so the problem only affects existing libraries. This is why having an option for displaying the name as is (without sanitization) might work for existing libs as the developer will be responsible for using the option. |
I'm really liking this feature. I'd also like to maintain the dots in the library name. Although I think it would be better if there was MSBuild property to set it to cater for everyone. It would also be great if we could override the destination folder from "_content" to something else e.g. "assets". |
I'm using preview8 and static files(inside component libraries) doesn't seem to work in server-side Blazor. Am I right? Any eta? |
Hi @arivoir . It looks like you are posting on a closed issue! We're very likely to lose track of your bug/feedback/question unless you:
|
Scope
We want to support building and shipping class libraries that include static content. This can include support for discovering and injecting these static assets at runtime where appropriate.
We also want to make it possible to do local development with multiple projects containing static files. This means that in development, it would be possible to serve files from multiple projects wwwroot folders.
These are both features that Blazor had prior to mondo-ization.
The text was updated successfully, but these errors were encountered: