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

@db-ux/core-vite-plugin

v5.6.0

Published

Vite plugin for optimized DB UX Design System CSS imports

Readme

@db-ux/core-vite-plugin

Vite plugin for optimized DB UX Design System CSS imports. Automatically includes only the CSS you need based on components and classes used in your application.

Installation

npm install @db-ux/core-vite-plugin --save-dev

Usage

Basic Usage

Add the plugin to your vite.config.js or vite.config.ts:

import { defineConfig } from "vite";
import dbUxPlugin from "@db-ux/core-vite-plugin";

export default defineConfig({
	plugins: [dbUxPlugin()]
});

Then import the plugin in your CSS file:

/* styles.css or main.css */
@import "@db-ux/core-vite-plugin/index.css";

The plugin handles theme detection, component CSS, and foundation styles automatically.

Migration

If you're currently using the manual CSS layer imports, you can replace them with the plugin's single import:

/* Before */
@layer whitelabel-theme, db-ux;
@import "@db-ux/core-foundations/build/styles/theme/rollup.css"
	layer(whitelabel-theme);
@import "@db-ux/core-components/build/styles/bundle.css" layer(db-ux);
/* After */
@import "@db-ux/core-vite-plugin/index.css";

Advanced Usage

For more control, you can configure the plugin:

import { defineConfig } from "vite";
import dbUxPlugin from "@db-ux/core-vite-plugin";

export default defineConfig({
	plugins: [
		dbUxPlugin({
			include: {
				components: ["button", "input"], // Force include specific components
				foundations: ["helpers", "animations", "icons"], // Force include foundation features
				colors: ["neutral", "brand"], // Force include color schemes
				densities: ["regular", "functional"], // Force include densities
				fontSizes: ["body-md", "headline-lg"] // Force include font sizes
			},
			exclude: {
				components: ["tooltip"], // Exclude specific components
				foundations: ["elevation"], // Exclude foundation features
				colors: ["critical"], // Exclude color schemes
				densities: ["expressive"], // Exclude densities
				fontSizes: ["body-3xs"] // Exclude font sizes
			},
			optimize: true, // Remove unused CSS variable declarations to reduce bundle size (default: true).
			theme: "db-theme", // Specify preferred theme package name (e.g., "db-theme")
			additionalLayers: { after: ["ri-extension"] }, // Append custom layers to the auto-generated order
			debug: false // Generate detection report for debugging (default: false)
		})
	]
});

Configuration

include

  • Type: { components?: Component[], foundations?: FoundationFeature[], colors?: ColorScheme[], densities?: Density[], fontSizes?: FontSize[] }
  • Force include specific components, foundation features, color schemes, densities, or font sizes
  • Foundation features: icons, helpers, elevation, animations, code

exclude

  • Type: { components?: Component[], foundations?: FoundationFeature[], colors?: ColorScheme[], densities?: Density[], fontSizes?: FontSize[] }
  • Exclude specific components, foundation features, color schemes, densities, or font sizes

optimize

  • Type: boolean
  • Default: true
  • Remove unused CSS variable declarations to reduce bundle size

theme

  • Type: string
  • Default: undefined
  • Specify a preferred theme package name (e.g., "db-theme"). The plugin automatically detects installed theme packages from @db-ux/*-theme or @db-ux-inner-source/*-theme. Use this option to select a specific theme when multiple are available.

additionalLayers

  • Type: { before?: string[], after?: string[] }
  • Default: undefined
  • Append custom CSS cascade layers before or after the auto-generated layer order. Useful when your project defines its own layers on top of DB UX.
// Adds layers around the auto-generated ones
dbUxPlugin({
	additionalLayers: {
		before: ["reset"],
		after: ["ri-extension"]
	}
});
// → @layer reset, db-theme, db-ux, ri-extension;

overrideLayers

  • Type: string[]
  • Default: undefined
  • Fully replace the auto-generated @layer statement with a custom layer order. When set, additionalLayers is ignored.
dbUxPlugin({
	overrideLayers: ["db-theme", "db-ux", "ri-extension"]
});
// → @layer db-theme, db-ux, ri-extension;

debug

  • Type: boolean
  • Default: false
  • Generate a db-ux-detection-report.json file in the project root directory for debugging purposes. This report contains all detected components, colors, densities, and font sizes. Useful for troubleshooting optimization issues.

How it works

The plugin analyzes your source files to detect:

  • DB UX component usage (e.g., class="db-button")
  • Custom classes using design tokens
  • Explicitly configured includes/excludes

It then generates an optimized CSS bundle containing only:

  • Required foundation styles (theme, fonts, icons)
  • Component styles for detected components
  • Optional features based on configuration

Troubleshooting

Plugin Order with Tailwind CSS

If you're using Tailwind CSS alongside this plugin, the order matters. The @db-ux/core-vite-plugin must be placed before the Tailwind plugin in your Vite configuration:

import { defineConfig } from "vite";
import dbUxPlugin from "@db-ux/core-vite-plugin";
import tailwindcss from "@tailwindcss/vite";

export default defineConfig({
	plugins: [
		dbUxPlugin(), // Must come before tailwindcss()
		tailwindcss()
	]
});

And in your CSS file:

@import "tailwindcss";
@import "@db-ux/core-vite-plugin/index.css";

Why? The DB UX plugin needs to process and replace the @import "@db-ux/core-vite-plugin/index.css" statement with actual CSS before Tailwind processes the file. Tailwind will strip out unrecognized imports, so the DB UX plugin must run first to transform the import into valid CSS that Tailwind can then process.

CSS @property Warnings

You may see warnings about "Unknown at rule: @property" in your build output or IDE. These are informational warnings from CSS parsers that don't yet fully support the CSS Houdini @property at-rule. These warnings don't affect functionality - the @property rule is valid CSS and works correctly in modern browsers. You can safely ignore these warnings or configure your CSS linter to suppress them.

Styles Not Loading in Dev Mode with <link> Tags

If you load your CSS via a <link> tag in index.html:

<!-- ❌ This won't work with the plugin in dev mode -->
<link rel="stylesheet" href="/src/styles.css" />

The plugin's transform hook only runs for CSS that is part of Vite's module graph. Static <link> tags are served as-is by Vite's dev server, so the @import "@db-ux/core-vite-plugin/index.css" inside the CSS file is never processed.

Solution: Import the CSS from your JavaScript/TypeScript entry file instead:

// main.ts or main.tsx
import "./styles.css";

This pulls the CSS into Vite's module graph where the plugin can transform it. The production build is not affected by this issue.

License

This project is licensed under Apache-2.0.