Live Chat Icon For mobile
Live Chat Icon

How do you bundle and minify the CSS and JS files in Blazor applications?

Platform: Blazor| Category : General, Tips and Tricks

Bundling is the process of combining multiple files into a single file. Minifying is the process of removing unnecessary data such as comments and extra spaces, as well as converting a large variable name into a smaller name without affecting its functionalities.

To bundle and minify the CSS and JS files in a Blazor application, follow these steps:

  1. Install the BuildBundlerMinifier NuGet package and reference it in the .csproj file, as shown.


        <Project Sdk="Microsoft.NET.Sdk.Web">
        <PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />

  2. Create a new .json file named bundleconfig.json and add the following code to bundle and minify the CSS and JS files.


        "outputFileName": "wwwroot/css/bundle.min.css",
        "inputFiles": [
        "outputFileName": "wwwroot/scripts/bundle.min.js",
        "inputFiles": [
        "minify": {
          "enabled": true,
          "renameLocals": true
        "sourceMap": false

  3. After you build your application, the bundled and minified files are generated as shown in the following image. You can reference these files in your application based on the requirement.


    View Sample in GitHub

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.