ESBuild.AspNetCore
0.28.0.2
dotnet add package ESBuild.AspNetCore --version 0.28.0.2
NuGet\Install-Package ESBuild.AspNetCore -Version 0.28.0.2
<PackageReference Include="ESBuild.AspNetCore" Version="0.28.0.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="ESBuild.AspNetCore" Version="0.28.0.2" />
<PackageReference Include="ESBuild.AspNetCore"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add ESBuild.AspNetCore --version 0.28.0.2
#r "nuget: ESBuild.AspNetCore, 0.28.0.2"
#:package ESBuild.AspNetCore@0.28.0.2
#addin nuget:?package=ESBuild.AspNetCore&version=0.28.0.2
#tool nuget:?package=ESBuild.AspNetCore&version=0.28.0.2
ESBuild.AspNetCore
ESBuild.AspNetCore is a build-time TypeScript bundling package for ASP.NET Core projects powered by esbuild (GitHub). It was inspired by AspNetCore.SassCompiler, with the same goal of making asset compilation work as a NuGet-powered MSBuild integration instead of a separate Node-based toolchain step.
This repository is currently 100% AI-generated code. Because of that, no pull request will be accepted without prior approval from the maintainer. If you want to contribute, open an issue first and wait for confirmation before investing time in a PR.
What it does
- Reads configuration exclusively from
esbuild.json - Runs
esbuildduringdotnet buildanddotnet publish - Ships platform-specific
esbuildbinaries inside the NuGet package - Adds generated files back into the ASP.NET Core static file/publish pipeline
- Supports Debug/Release defaults and configuration-specific per-bundle overrides
What it does not do
- It does not read
appsettings.json - It does not require changes to
Program.cs - It does not provide watch mode, hot reload integration, or runtime bundling
- It does not require Node.js or a global
esbuildinstallation
Installation
Add the package to an ASP.NET Core project:
dotnet add package ESBuild.AspNetCore
Then create an esbuild.json file in the project root.
Minimal example
esbuild.json
{
"Bundles": [
{
"EntryPoint": "Scripts/site.ts",
"Output": "wwwroot/js/site.js"
}
],
"Configurations": {
"Debug": {
"Defaults": {
"Minify": false,
"Sourcemap": true
}
},
"Release": {
"Defaults": {
"Minify": true,
"Sourcemap": false
}
}
}
}
After that, dotnet build will generate wwwroot/js/site.js.
Configuration model
Top-level shape:
{
"Defaults": {},
"Bundles": [],
"Configurations": {}
}
Defaults
Supported default fields:
MinifySourcemapTargetFormatPlatform
Built-in package defaults:
Minify: falseSourcemap: trueTarget: "es2020"Format: "iife"Platform: "browser"
Bundles
Each bundle supports:
EntryPointOutputOutdirOptionalSplittingMinifySourcemapTargetFormatPlatformExternalDefineAliasLoaderPublicPath
Rules:
- Each bundle must define
EntryPoint - Each bundle must define exactly one of
OutputorOutdir SplittingrequiresOutdirSplittingrequiresFormat: "esm"Optional: trueskips the bundle if the entry point file does not exist
Configurations
Each configuration can contain:
DefaultsBundles
Configurations.<name>.Defaults overrides root defaults for that build configuration.
Configurations.<name>.Bundles applies per-bundle overrides matched by EntryPoint. Override entries must define EntryPoint, and that EntryPoint must match exactly one root bundle.
Example: configuration-specific bundle override
This allows Debug and Release to output different files:
{
"Bundles": [
{
"EntryPoint": "Scripts/site.ts",
"Output": "wwwroot/js/site.js"
}
],
"Configurations": {
"Debug": {
"Defaults": {
"Minify": false,
"Sourcemap": true
}
},
"Release": {
"Defaults": {
"Minify": true,
"Sourcemap": false
},
"Bundles": [
{
"EntryPoint": "Scripts/site.ts",
"Output": "wwwroot/js/site.release.js"
}
]
}
}
}
Example: splitting with Outdir
{
"Bundles": [
{
"EntryPoint": "Scripts/site.ts",
"Outdir": "wwwroot/js",
"Splitting": true,
"Format": "esm"
}
]
}
When splitting is enabled, the package tracks emitted chunk files using esbuild metafile output and persists the discovered output set under obj/ESBuild.AspNetCore.
Merge behavior
Effective bundle settings are resolved in this order:
- Package defaults
- Root
Defaults - Root bundle values
- Configuration
Defaults - Configuration-specific bundle override values
If a configuration-specific bundle override specifies Output, it replaces Outdir. If it specifies Outdir, it replaces Output.
Supported platforms
The package currently ships vendored esbuild binaries for:
- Windows x64
- Windows arm64
- Linux x64
- Linux arm64
- macOS x64
- macOS arm64
Diagnostics
Typical failure cases:
- missing
EntryPoint - missing both
OutputandOutdir - defining both
OutputandOutdir - unsupported
Format - unsupported
Platform Splittingused withoutOutdirSplittingused with a format other thanesm- invalid configuration-specific bundle override matching
Builds fail with explicit error messages for invalid configuration.
Repository notes
- This project is intentionally build-time only
- Configuration comes only from
esbuild.json appsettings.jsonconfiguration is ignored- Generated files are included in normal ASP.NET Core content/publish output
Contributing
Open an issue before opening a PR. Unapproved pull requests should be assumed likely to be closed without merge, especially while the repository is still stabilizing its AI-generated foundation.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.