npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

aspnet-buildtools

v0.3.4

Published

Vite and Webpack entry points and import aliases generated from ASP.NET Core Razor views

Readme

aspnet-buildtools

npm version npm downloads CI License: MIT

Vite and Webpack configuration for ASP.NET Core MVC and Razor Pages. aspnet-buildtools scans your project for Razor views and creates one entry point per view, plus import aliases for the project root and each area. Put an Index.cshtml.js next to Views/Home/Index.cshtml and it becomes the Views_Home_Index bundle.

It is the frontend half of AspNet.AssetManager, which renders the matching <script> and <link> tags in your views.

Install

npm install --save-dev aspnet-buildtools

Requires Node.js 22 or later, and Vite 8+ or Webpack 5. For Vite 7 and earlier, use [email protected].

How it works

Run your bundler from the ASP.NET Core project folder. aspnet-buildtools finds these entry points:

| File | Bundle name | | ---------------------------------------------- | ------------------------------ | | Views/Home/Index.cshtml.js | Views_Home_Index | | Pages/Account/Login.cshtml.ts | Pages_Account_Login | | Areas/Admin/Views/Users/Edit.cshtml.js | Areas_Admin_Views_Users_Edit | | Assets/bundles/Layout.bundle.js (any folder) | Layout |

  • A .cshtml.js / .cshtml.ts file is only used if a .cshtml file with the same name exists next to it.
  • Partial views (_*.cshtml), view components (Components/*/) and node_modules are skipped.
  • *.bundle.js / *.bundle.ts files are named after the file, without the .bundle part.

It also sets up import aliases:

| Alias | Resolves to | | ---------- | ---------------------------------------------- | | @/ | The project root | | @<Area>/ | Areas/<Area>/, for each area, e.g. @Admin/ |

// Views/Home/Index.cshtml.js
import '@/Assets/css/site.css';
import { initGrid } from '@Admin/Shared/grid.js';

Vite

// vite.config.js
import { viteConfig } from 'aspnet-buildtools';
import { defineConfig } from 'vite';

export default defineConfig({
  ...viteConfig,
  build: {
    ...viteConfig.build,
    assetsDir: '',
    manifest: 'assets-manifest.json',
    outDir: 'wwwroot/dist',
  },
  server: {
    cors: true,
  },
});

Vite only writes a manifest when building. viteConfig includes viteDevManifestPlugin(), which serves a manifest from the dev server at the build.manifest path. AspNet.AssetManager can then find your entry points in development too.

  • Set build.manifest to the same file name as ManifestFile in AspNet.AssetManager.
  • If you use manifest: true, the dev manifest is served at /.vite/manifest.dev.json and the production manifest is written to .vite/manifest.json. In that case, set ManifestFile separately in appsettings.Development.json.

To pick the parts yourself:

// vite.config.js
import {
  getAliases,
  getEntryPoints,
  viteDevManifestPlugin,
} from 'aspnet-buildtools';
import { defineConfig } from 'vite';

export default defineConfig({
  build: {
    manifest: 'assets-manifest.json',
    rolldownOptions: {
      input: getEntryPoints(),
    },
  },
  resolve: {
    alias: getAliases(),
  },
  plugins: [viteDevManifestPlugin()],
});

Webpack

// webpack.config.js
import { webpackConfig } from 'aspnet-buildtools';
import { WebpackAssetsManifest } from 'webpack-assets-manifest';

export default {
  ...webpackConfig,
  plugins: [new WebpackAssetsManifest()],
};

To pick the parts yourself:

// webpack.config.js
import { getAliases, getEntryPoints } from 'aspnet-buildtools';

export default {
  entry: getEntryPoints(),
  resolve: {
    alias: getAliases(),
  },
};

Webpack only picks up new entry points when the dev server restarts.

API

| Export | Description | | -------------------------- | ---------------------------------------------------------------------------------------- | | getEntryPoints(context?) | Returns { [bundleName]: absolutePath } for all entry points under context. | | getAliases(context?) | Returns { '@': root, '@<Area>': areaPath }. | | viteDevManifestPlugin() | Vite plugin that serves a manifest of build.rolldownOptions.input from the dev server. | | viteConfig | Partial Vite config with entry points, aliases and the dev manifest plugin. | | webpackConfig | Partial Webpack config with context, entry points and aliases. |

context defaults to process.cwd(). viteConfig and webpackConfig are built from process.cwd() when the module is loaded.

Related projects

Development

npm ci
npm run lint
npm test
npm run build

License

MIT