Skip to content

Korgys/WebBundler

WebBundler

Build Status Last Commit Coverage Quality Gate Status Lines of Code Duplicated Lines (%) Security Rating .NET Platform License

Bundle and minify web assets in .NET projects without Node.js.

WebBundler is a lightweight, deterministic and CI-friendly asset bundler for .NET web applications.

It helps you bundle and minify CSS and JavaScript files without requiring Node.js, npm, Vite, Webpack, Rollup or any heavy frontend toolchain.

NuGet packages :

Why use WebBundler?

Many .NET web projects do not need a full JavaScript build stack.

Sometimes you only need to:

  • combine a few CSS files
  • bundle JavaScript files in a fixed order
  • minify outputs during build
  • generate fingerprinted assets
  • produce a manifest file for cache-busting
  • run the same behavior locally and in CI/CD
  • keep the asset pipeline inside the .NET ecosystem

WebBundler is built for this use case.

Quick start

1. Create a bundleconfig.json file

Create a bundleconfig.json file at the root of your project:

{
  "$schema": "https://raw.githubusercontent.com/korgys/WebBundler/main/schemas/bundleconfig.v1.schema.json",
  "version": 1,
  "manifestOutput": "wwwroot/dist/webbundler.manifest.json",
  "bundles": [
    {
      "output": "wwwroot/dist/site.min.css",
      "inputs": ["wwwroot/css/reset.css", "wwwroot/css/site.css"],
      "type": "css",
      "minify": true,
      "fingerprint": true,
      "sourceMap": true
    },
    {
      "output": "wwwroot/dist/site.min.js",
      "inputs": ["wwwroot/js/vendor/*.js", "wwwroot/js/app.js"],
      "type": "js",
      "minify": true,
      "fingerprint": true,
      "sourceMap": true
    }
  ]
}

2. Install and run the CLI

Install the tool from NuGet:

dotnet tool install --global WebBundler.Tool

Run it from the project root:

webbundler validate --config bundleconfig.json
webbundler check --config bundleconfig.json
webbundler build --config bundleconfig.json

Usage

Command Purpose Writes files
webbundler validate Validates configuration structure only No
webbundler check Validates configuration and resolves asset inputs No
webbundler build Builds bundles, source maps, and any configured manifest Yes

3. Or integrate with MSBuild

Add the package to a web project:

<ItemGroup>
  <PackageReference Include="WebBundler.MSBuild" Version="1.0.0" PrivateAssets="all" />
</ItemGroup>

The build target looks for bundleconfig.json in the project directory by default and runs once per build or publish invocation.

Useful MSBuild properties:

  • WebBundlerConfigFile: path to the configuration file.
  • WebBundlerEnabled: enables or disables WebBundler during build.
  • WebBundlerEnableFingerprinting: globally enables fingerprinted outputs.
  • WebBundlerWriteOutputs: controls whether output files are written.

Features

Current capabilities include:

  • CSS and JavaScript minification
  • CSS and JavaScript bundling
  • fingerprinted output files
  • CLI usage, CI/CD support
  • MSBuild integration
  • JSON configuration via bundleconfig.json
  • versioned JSON Schema for IDE completion
  • manifest generation via manifestOutput
  • external sibling .map source maps for CSS and JavaScript

Design principles

WebBundler follows a few key principles:

  1. CLI-first for automation and scripting
  2. MSBuild-first for .NET project integration
  3. Visual Studio friendly, but not IDE-dependent
  4. Deterministic behavior so local and CI outputs match
  5. Simple configuration and explicit behavior
  6. Maintainable architecture with clean separation of concerns

Docs

See the docs above for examples and implementation details.

About

Bundle and minify web assets in .NET projects without Node.js. Fast, deterministic, and CI-friendly.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages