Is it possible to get full path of isolated JS/CSS assets for Blazor
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
The documentation about JavaScript isolated modules says to call import
to to get isolated JS reference:
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
module = await JS.InvokeAsync<IJSObjectReference>("import",
"./scripts.js");
}
}
The problem is the path of the JS file. Assuming we have Pages/CallJsExample6.razor
and Pages/CallJsExample6.razor.js
javascript module.
Then we should call await JS.InvokeAsync<IJSObjectReference>("import", "./Pages/CallJsExample6.razor.js")
.
Once we move CallJsExample6.razor
to the external class library, it will have a path like ./_content/ExternalAssemblyName/Components/CallJsExample6.razor.js
.
So, the question is whether it’s possible to resolve asset’s path after project publishing in runtime?
Describe the solution you’d like
Something like var path = Resolver.GetContentPath('./Pages/CallJsExample6.razor.js');
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
ASP.NET Core Blazor CSS isolation
Learn how CSS isolation scopes CSS to Razor components, which can simplify CSS and avoid collisions with other components or libraries.
Read more >c# - Embed JavaScript files inside a .NET class library for ...
The path segment for the current directory (./) is required in order to create the correct static asset path to the JS file....
Read more >Use CSS isolation in your Blazor projects - Dave Brock
Reminder: CSS isolation is a build-time step To support isolation, Blazor rewrites all the CSS selectors during the build process. This makes ...
Read more >What is Blazor CSS isolation? How do you enable it for ...
razor,” create a file alongside the component named “Isolate.razor.css.” The Isolate.razor.css file is placed in the same folder as the Isolate.razor component.
Read more >Getting a file path from a user : r/Blazor
Yes this would work, so creating a component which uses Directory.GetFiles for the share path and displaying them as a listing?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.
Actually, the problem is not solved, not sure why it’s closed 😕