Open Closed

Bundling JS files in Blazor Server #9799


User avatar
0
bmulinari created

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)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    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:

    1. 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.
    2. 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.
    3. 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:


    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.

  • User Avatar
    0
    bmulinari created

    I appreciate the AI-generated response, but I'd like to hear the ABP team's input on this matter.

    Thanks!

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi Your App.razor has AbpStyles and AbpScripts 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.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    If it's still not working. You can share the code and steps to reproduce your problem with a new template project.

    Thanks.

Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 12, 2025, 10:20