Skip to content
ASP.NET Core Tag Helper for Webpack assets
Branch: master
Clone or download

Latest commit


Type Name Latest commit message Commit time
Failed to load latest commit information.
samples Added parser for assets-webpack-plugin Nov 16, 2019
src Add tests for AssetManifestParser Nov 16, 2019
.editorconfig Initial commit Nov 13, 2019
.gitignore Added parser for assets-webpack-plugin Nov 16, 2019
LICENSE Initial commit Nov 13, 2019 Improve readme Nov 16, 2019
WebpackTag.sln Added parser for assets-webpack-plugin Nov 16, 2019


NuGet version

WebpackTag is an ASP.NET Core Tag Helper for rendering links to CSS and JS files compiled via Webpack


Install the WebpackTag library using NuGet

Add the WebpackTag services to your Startup.cs:

using WebpackTag;
public void ConfigureServices(IServiceCollection services)

Import the tag helpers in your Views/_ViewImports.cshtml file:

@addTagHelper *, WebpackTag

Then use the tag helpers in your view!

<webpack-styles />
<webpack-scripts />

These tag helpers will look for files called webpack-assets.json or asset-manifest.json in your wwwroot or SPA root directory, parse the contents, and render the correct <link> or <style> tags.

Note that when using assets-webpack-plugin, the entrypoints option should be enabled.

Multiple entry points

If your app has multiple entry points, you may specify the entry point name when using the tag

<webpack-styles entry="first" />


Additional configuration can be performed when registering the services:

services.AddWebpackTag(options =>
	// ...

The following configuration options are available:

  • DevServerPort: Port the Webpack devserver is running on. If this is configured, the tag helpers will try hitting http://localhost:{port}/asset-manifest.json to load the manifest.
  • BaseUrl: Sets a string to prefix the generated URLs with. For example, this can be used to use a separate CDN domain in prod:
public class Startup
	private readonly IWebHostEnvironment _env;

	public Startup(IConfiguration configuration, IWebHostEnvironment env)
		_env = env;
		Configuration = configuration;

	public void ConfigureServices(IServiceCollection services)
		services.AddWebpackTag(options =>
			options.BaseUrl = _env.IsDevelopment() ? "/" : "";
		// ...


This repository contains two samples:

You can’t perform that action at this time.