Hi,
From what I could find in the documentation and in this article, bundling JavaScript or CSS files is only mentioned for Blazor WebAssembly, no mention of Blazor Server. From my tests the BundleContributor
approach does not seem to work for Blazor Server.
For now the workaround has been collocated JavaScript files with specific components.
Does ABP offer any way to do file bundling in Blazor Server? What would be the correct approach?
4 Answer(s)
-
0
For Blazor Server applications, ABP Framework does not provide a built-in, automatic JavaScript/CSS bundling system like the "Global Assets" feature available for Blazor WebAssembly. The documentation and referenced article specifically address Blazor WebAssembly, and the BundleContributor approach is not supported for Blazor Server.
In Blazor Server, the recommended approaches are:
- Use standard ASP.NET Core bundling and minification techniques, such as configuring bundles in your Startup/Program class or using third-party tools (e.g., WebOptimizer, Gulp, or Webpack) to bundle and minify your static assets.
- For component-specific scripts, continue using collocated JavaScript files as described in the official Blazor documentation. This is the standard way to manage per-component JS interop in Blazor Server.
- If you want to bundle global scripts/styles, you can manually include bundled files (created by your chosen tool) in your _Host.cshtml or Layout file.
There is currently no ABP-specific abstraction or automation for bundling static files in Blazor Server projects. The ABP bundling system and BundleContributor pattern are designed for MVC and Blazor WebAssembly scenarios.
Sources:
- Validated: ABP Blazor Global Scripts & Styles
- Validated: ABP Global Assets Article
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
I appreciate the AI-generated response, but I'd like to hear the ABP team's input on this matter.
Thanks!
-
0
hi Your
App.razor
hasAbpStyles
andAbpScripts
components to get bundling js/css.<AbpStyles BundleName="@BlazorLeptonXThemeBundles.Styles.Global" /> <AbpScripts BundleName="@BlazorLeptonXThemeBundles.Scripts.Global" />
It will use the MVC Bundling & Minification system.
see https://abp.io/docs/latest/framework/ui/mvc-razor-pages/bundling-minification
Thanks.
-
0
If it's still not working. You can share the code and steps to reproduce your problem with a new template project.
Thanks.