EdCharbeneau/BlazorPro.Spinkit

Publish _content to to <base href="/myroot/">

Closed this issue · 3 comments

https://github.com/javiercn/BlazorMultipleApps
I am using the above starter project as a baseline to make sure that I can have multiple client-side blazor apps that are all under one host.

You can see for the index.html that context is given using the following;

 <base href="/SecondApp/" />

The way the publish knows what folder to put it into is in the SecondBlazorApp.Client.csproj using the <StaticWebAssetBasePath>SecondApp</StaticWebAssetBasePath>

<PropertyGroup>
    <StaticWebAssetBasePath>SecondApp</StaticWebAssetBasePath>
</PropertyGroup>

doing a publish will result in all my content, including blazors _framework, will be put in a folder called SecondApp

As a component author how do I make sure that my static content is also published correctly under the /SecondApp/ folder.

As it is now, if I have 2 client side blazor apps they will collide as both simply publish to _content/ instead of /SecondApp/_content and /ThirdApp/_content

I want to be able to have different versions of BlazorPro.SpinKit and it should work because the stacks have the correct context (<base href="/TheContext/").

The expectation would be that component libraries honor csproj directive;

<StaticWebAssetBasePath>SecondApp</StaticWebAssetBasePath>

This is an interesting question. Since I've never experienced this I can only reiterate what I've read.

It appears that adding <StaticWebAssetBasePath> to your Razor Class Library (RCL) only effects the RCL itself.

Given a RCL called Foo
And the <StaticWebAssetBasePath>/foo</StaticWebAssetBasePath>
When I consume Foo in my project
Then the resulting path for static assets is /foo/*.css
Also, there is nothing at path _content/

From what I've read there's nothing you can do at the consumer level to change this path.
base href="" seems to have no effect on StaticWebAssetBasePath

I'm not sure how you should resolve this, but it doesn't appear that there are any tools as a package author of 3rd party packages.

@ghstahl does anything in this thread help? dotnet/aspnetcore#14568

blazor issue
I wrote about the work around I have to do to make things not collide.

The issue is that publish doesn't account for the client-side BlazorApp(s) third party references when <StaticWebAssetBasePath>/SencondApp</StaticWebAssetBasePath> is in play.
The {thirdPary}/_content folders are ignored and end up in;

wwwroot/_content/{thirdparty}/somefile.js

The problem happens when you look at a ThirdApp project. ThirdApp also has a reference to a {thirdparty library}. When both SencondApp and ThirdApp get referenced in the hosting app their wwwroot/_content folders will collide. If SencondApp references ThirdParty.v1.0 and ThirdApp references ThirdParty.v1.2, its anyone's guess what the final files will be when you look at;

{hostingApp}/wwwroot/_content/ThirdParty/somefile.js. (v1.0 or v1.2)

No such problem when it gets published to ;

{hostingApp}/wwwroot/SecondApp/_content/ThirdParty/somefile.js (v1.0)   
{hostingApp}/wwwroot/ThirdApp/_content/ThirdParty/somefile.js (v1.2)

I did look at the dotnet/aspnetcore#14568 issue and I think that is ultimately what the Visual Studio team is going to have to do to fix it in tooling. I like my workaround for now as its understandable and may only work when I build this stuff in github actions.

This is something I haven't been asked before, so I appreciate you bring up the issue so I'm aware of it.

I think you're correct that the VS team will have to fix this in order for it to work out-of-the-box.

In regards to SpinKit. You can grab the CSS from the GitHub repo and place it anywhere in your project you like and ignore the one packaged within the RCL. Since SpinKit is based on another OSS you can even get it on CDN.

https://www.cdnpkg.com/spinkit

Changed to documentation and closing.