# @tailwindcss-mangle/engine

> Tailwind CSS candidate extraction and style generation engine for tailwindcss-mangle

Latest version **0.2.0** (published 2026-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tailwindcss-mangle/engine
pnpm add @tailwindcss-mangle/engine
yarn add @tailwindcss-mangle/engine
bun add @tailwindcss-mangle/engine
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2026-07-17 |
| First published | 2026-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.20.0 |
| Dependencies | 5 |
| Unpacked size | 654.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 214 |
| Author | ice breaker <1324318532@qq.com> |
| Maintainers | icebreaker |
| Keywords | tailwindcss, engine, extract, class, mangle |

## Links

- npm: https://www.npmjs.com/package/@tailwindcss-mangle/engine
- Repository: https://github.com/sonofmagic/tailwindcss-mangle
- Homepage: https://mangle.icebreaker.top/
- Issues: https://github.com/sonofmagic/tailwindcss-mangle/issues
- npm.io page: https://npm.io/package/@tailwindcss-mangle/engine

## Dependencies (5)

- [pathe](https://npm.io/package/pathe.md) ^2.0.3
- [postcss](https://npm.io/package/postcss.md) ^8.5.19
- [micromatch](https://npm.io/package/micromatch.md) ^4.0.8
- [@tailwindcss/node](https://npm.io/package/@tailwindcss/node.md) ^4.3.3
- [@tailwindcss/oxide](https://npm.io/package/@tailwindcss/oxide.md) ^4.3.3

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads
- [@modern-js/plugin-swc](https://npm.io/package/@modern-js/plugin-swc.md) — 3.4K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2026-07-17
- 0.1.3 — 2026-07-07
- 0.1.2 — 2026-06-30
- 0.1.1 — 2026-06-24
- 0.1.0 — 2026-06-18
- 0.0.0 — 2026-06-18

## README

# @tailwindcss-mangle/engine

Tailwind CSS candidate extraction and style generation engine for
tailwindcss-mangle.

This package contains the reusable engine pieces shared by
`tailwindcss-patch` and downstream integrations. It does not patch a local
Tailwind CSS installation or write patch artifacts by itself.

## Install

```bash
pnpm add @tailwindcss-mangle/engine
```

Tailwind CSS is a peer dependency. Install the Tailwind version that your
project needs:

```bash
pnpm add tailwindcss
```

## Usage

### Extract candidates

```ts
import { extractSourceCandidates } from "@tailwindcss-mangle/engine";

const candidates = await extractSourceCandidates(
  '<view class="text-red-500 rounded-[18px]"></view>',
  "wxml",
);

console.log(candidates);
```

Collect explicit candidates and candidates extracted from source snippets:

```ts
import { collectTailwindStyleCandidates } from "@tailwindcss-mangle/engine";

const tokens = await collectTailwindStyleCandidates({
  candidates: ["text-red-500"],
  sources: [
    {
      content: '<view class="min-h-screen rounded-[18px]"></view>',
      extension: "wxml",
    },
  ],
});
```

### Generate Tailwind v4 CSS

```ts
import { generateTailwindStyle } from "@tailwindcss-mangle/engine";

const result = await generateTailwindStyle({
  version: 4,
  css: '@import "tailwindcss";',
  candidates: ["text-red-500"],
  sources: [
    {
      content: '<view class="rounded-[18px]"></view>',
      extension: "wxml",
    },
  ],
});

console.log(result.css);
```

Reuse a Tailwind v4 compilation session when an integration needs structured
PostCSS artifacts and explicit invalidation:

```ts
import {
  createTailwindGenerationSession,
  resolveTailwindV4Source,
} from "@tailwindcss-mangle/engine";

const source = await resolveTailwindV4Source({
  projectRoot: process.cwd(),
  css: '@import "tailwindcss";',
});
const session = createTailwindGenerationSession(source);
const artifact = await session.generate({
  candidates: ["text-red-500"],
  sourceEntries: [
    {
      id: "virtual:page.wxml",
      extension: "wxml",
      content: '<view class="rounded-[18px]"></view>',
    },
  ],
});

console.log(artifact.fragments[0]?.root.toString());
session.invalidate({ type: "dependencies" });
session.dispose();
```

### Generate Tailwind v3 CSS

```ts
import { generateTailwindStyle } from "@tailwindcss-mangle/engine";

const result = await generateTailwindStyle({
  version: 3,
  candidates: ["text-red-500"],
  config: {
    corePlugins: {
      preflight: false,
    },
  },
});

console.log(result.css);
```

### Generate custom CSS

```ts
import { generateTailwindStyle } from "@tailwindcss-mangle/engine";

const result = await generateTailwindStyle({
  version: "custom",
  candidates: ["token-card"],
  generate({ tokens }) {
    return [...tokens]
      .map((token) => `.${token}{--tw-token:"${token}"}`)
      .join("\n");
  },
});
```

## Entry Points

- `@tailwindcss-mangle/engine`: public extraction and style generation APIs.
- `@tailwindcss-mangle/engine/v3`: Tailwind v3-specific style generation.
- `@tailwindcss-mangle/engine/v4`: Tailwind v4-specific source resolution and style generation.

## Development

```bash
pnpm --filter @tailwindcss-mangle/engine build
pnpm --filter @tailwindcss-mangle/engine test
pnpm --filter @tailwindcss-mangle/engine test:types
```

---
_Source: https://npm.io/package/@tailwindcss-mangle/engine · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
