LayerZero.Tools.Web
1.1.1
See the version list below for details.
dotnet add package LayerZero.Tools.Web --version 1.1.1
NuGet\Install-Package LayerZero.Tools.Web -Version 1.1.1
<PackageReference Include="LayerZero.Tools.Web" Version="1.1.1" />
<PackageVersion Include="LayerZero.Tools.Web" Version="1.1.1" />
<PackageReference Include="LayerZero.Tools.Web" />
paket add LayerZero.Tools.Web --version 1.1.1
#r "nuget: LayerZero.Tools.Web, 1.1.1"
#:package LayerZero.Tools.Web@1.1.1
#addin nuget:?package=LayerZero.Tools.Web&version=1.1.1
#tool nuget:?package=LayerZero.Tools.Web&version=1.1.1
📦 Dynamic Bundle Loader for ASP.NET Core
A convention-based asset bundling system for .NET 8+ using WebOptimizer. Automatically discovers and injects CSS/JS bundles per controller and action using Razor TagHelpers.
🔍 Purpose
Eliminates manual asset management in Razor views by scanning controller/action folder structures and auto-generating optimized bundles at runtime.
🗂 Folder Convention
wwwroot/
+---css
| | site.css
| |
| +---Controller
| | \---Home
| | | Home.css
| | |
| | +---Index
| | | StyleSheet.css
| | |
| | \---Privacy
| | StyleSheet.css
| |
| \---critical
| StyleSheet-cr1.css
| StyleSheet-cr2.css
|
+---js
| | site.js
| |
| \---Controller
| \---Home
| | Script.js
| |
| +---Index
| | Script.js
| |
| \---Privacy
| flickity.pkgd.min.js
| JavaScript.js
|
\---lib
Controller/Action
structure drives bundle discovery. nd a special folder for critical CSS
⚙️ Installation
1. Add the NuGet Package
dotnet add package LayerZero.Tools.Web
Or reference the project directly:
dotnet new classlib -n DynamicBundleLoader
dotnet add reference ../DynamicBundleLoader/DynamicBundleLoader.csproj
2. NuGet Dependencies
<PackageReference Include="LigerShark.WebOptimizer.Core" Version="3.0.456" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
🚀 Usage
Register in Program.cs
builder.Services.AddDynamicBundle();
Or if you want to enable cache-busting on dev environment:
builder.Services.AddDynamicBundle(builder.Environment);
Enable Middleware
app.UseWebOptimizer();
🧠 TagHelpers
Register in _ViewImports.cshtml
@addTagHelper *, LayerZero.Tools.Web
Use in _Layout.cshtml
<head>
<critical-style-bundle-loader/>
<style-bundle-loader />
</head>
<body>
@RenderBody()
<script-bundle-loader />
</body>
Action-specific bundles override controller-wide ones.
💡 Features
✅ Convention-over-configuration
✅ Minification only in production
✅ Controller & action bundle granularity
✅ TagHelpers for clean layout injection
✅ Auto-registers bundles at startup
✅ Inline critical CSS (with skip support)
✅ Cache-busting in development mode
🔒 Minification Mode
Minification is automatically applied only in production. When isDevelopment
is true, JS/CSS are included unminified for easier debugging.
🔥 Critical CSS (v1.1.0+)
- Combines all
.css
files underwwwroot/css/critical/
into a single<style>
tag. - Injected above all other stylesheets.
🚫 Cache-Busting in Development
To prevent browser caching during local testing, development mode appends ?v=<random>
to asset URLs.
<link rel="stylesheet" href="/bundles/home.min.css?v=46174bc4-f61a-4382-a733-81ffe8c73074" />
In production, clean URLs are used for optimal caching.
✨ Example
Requesting /Home/Index
loads:
<style>/* critical CSS injected here */</style>
<link rel="stylesheet" href="/bundles/home.min.css" />
<link rel="stylesheet" href="/bundles/home/index.min.css" />
<script src="/bundles/home.min.js"></script>
<script src="/bundles/home/index.min.js"></script>
⚠️ Limitations in v1.1.0
While the current version provides automated and scoped asset bundling, some customization options are deferred to future releases for architectural clarity.
🔒 Known Limitations
- ❌ Custom asset folder paths are not configurable via
AddDynamicBundle()
inv1.1.0
. - ❌ Dynamic runtime configuration of asset logic is not exposed yet.
- ✅ A static convention-based pathing system is in place (e.g.,
wwwroot/css/Controller/Action/...
).
These constraints preserve legacy compatibility and ensure minimal setup in v1.1.0
.
🛣 Planned for v2.0.0
A new configuration object will be introduced to allow:
- ✅ Custom
JsRoot
,CssRoot
,CriticalCssRoot
directories. - ✅ Optional feature toggles for minification, cache-busting, critical asset control.
- ✅ Fluent configuration syntax.
builder.Services.AddDynamicBundle(new DynamicBundleConfig
{
JsRoot = "wwwroot/assets/js",
CssRoot = "wwwroot/assets/css",
CriticalCssRoot = "wwwroot/assets/critical",
EnableCacheBusting = true
});
👤 Author
LayerZero Team — Built for clean architecture and developer clarity.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- AngleSharp.Css (>= 0.17.0)
- LayerZero.Tools (>= 1.0.1)
- LigerShark.WebOptimizer.Core (>= 3.0.436)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.