@knighted/css is a zero-bundler CSS pipeline for JavaScript and TypeScript projects. Point it at an entry module and it walks the graph, compiles every CSS-like dependency (CSS, Sass/SCSS, Less, vanilla-extract), and hands back both a concatenated stylesheet string and optional .knighted-css.* selector manifests for type-safe loaders.
- Graph walking: Follows
importtrees the same way Node does (tsconfigpaths, packageexports/imports, hash specifiers, etc.) usingoxc-resolver. - Multi-dialect compilation: Runs Sass, Less, Lightning CSS, or vanilla-extract integrations on demand so every dependency ends up as plain CSS.
- Loader + CLI: Ship CSS at runtime via
?knighted-cssloader queries or ahead of time via thecss()API and theknighted-css-generate-typescommand. - Shadow DOM + SSR ready: Inline styles in server renders, ship them alongside web components, or keep classic DOM apps in sync—all without wiring a full bundler.
See the docs/ directory for deep dives on loaders, type generation, specificity boosts, Sass aliases, the combined import queries, and the current 2026 roadmap.
| Workspace | NPM Name | What it contains |
|---|---|---|
packages/css |
@knighted/css |
The production library: graph walker, compilation pipeline, loader helpers, CLI, and docs. Published to npm and meant for real builds. |
packages/playwright |
@knighted/css-playwright-fixture |
The end-to-end demo + regression suite. Playwright drives Lit + React examples, hash-import workspace scenarios, and SSR checks to ensure the core package keeps working across bundlers. |
Each workspace is a standalone npm project. Run commands from the repo root with npm run <script> -w <workspace> or npm run <script> --workspaces to fan out when needed.
import { css } from '@knighted/css'
const sheet = await css('./src/entry.tsx', {
cwd: process.cwd(),
lightningcss: { minify: true },
})
console.log(sheet) // use during SSR, static builds, or to inline Shadow DOM styles- Need runtime imports? See docs/loader.md.
- Want strong selector types? Run
npx knighted-css-generate-typesand follow docs/type-generation.md. - Need the rundown on Node
exports/imports, Sass prefixes, or custom resolver hooks? Start with docs/resolution.md.
- Install deps with
npm install. - Run
npm run buildto compile@knighted/css. - Use
npm run testfor unit coverage andnpm run test:e2efor the Playwright matrix.
Issues and feature ideas are always welcome via GitHub issues.
MIT © Knighted Code Monkey