@aleph-alpha/config-unocss

中文文档
0.2.1发布于 2026/08/10Apache-2.0TypeScriptES Module近 30 天下载 1.4万

Shared UnoCSS presets for Aleph Alpha frontends. Re-exports the design-system token preset, web fonts preset, and helpers.

原始使用文档
文档目录5 节
  1. Config UnoCSS
  2. Installation
  3. Usage in applications
  4. Migration from legacy @aleph-alpha/config-css
  5. Exports

Config UnoCSS

@aleph-alpha/config-unocss

Shared UnoCSS presets for Aleph Alpha frontends. Bundles the design-system token preset, web-fonts preset, and content-pipeline helpers so every app and library can share one UnoCSS configuration.

The design tokens themselves live in @aleph-alpha/config-tokens, and the embedded web fonts live in @aleph-alpha/config-fonts; this package consumes both and exposes them as UnoCSS presets.

Installation

pnpm add -D @aleph-alpha/config-unocss

Usage in applications

Most apps just need:

// uno.config.ts
import { defineAppConfig } from '@aleph-alpha/config-unocss';

export default defineAppConfig();

defineAppConfig() wraps defineConfig from UnoCSS, pre-wires presetsAlephAlpha() and the design-system content paths, and exposes hooks for app-specific extension.

Layering on top

import { defineAppConfig } from '@aleph-alpha/config-unocss';

export default defineAppConfig({
  // Extra presets appended after the defaults
  presets: [/* presetMyApp() */],

  // Extra rules — e.g. local workarounds or brand utilities
  rules: [
    ['my-rule', { color: 'red' }],
  ],

  // Theme overrides — merged into the base theme
  theme: {
    breakpoints: { xs: '480px' },
    colors: { 'brand-bg-brand': '#CCE804' },
  },

  // Pull classes out of additional node_modules packages.
  // filesystem and pipeline.include are union-merged with the DS defaults.
  content: {
    filesystem: ['node_modules/@my-org/some-lib/**/*'],
  },

  // Pass-through options — anything `defineConfig` accepts
  shortcuts: { /* ... */ },
  safelist: [/* ... */],
  transformers: [/* ... */],
});

Composing manually (libraries, advanced apps)

import { defineConfig } from 'unocss';
import { presetsAlephAlpha, getDesignSystemContentPathConfig } from '@aleph-alpha/config-unocss';

export default defineConfig({
  presets: [...presetsAlephAlpha()],
  ...getDesignSystemContentPathConfig('vue'),
});

Migration from legacy @aleph-alpha/config-css

Before (~11 lines):

import {
  getDesignSystemContentPathConfig,
  presetAlephAlpha,
} from '@aleph-alpha/config-css';
import { defineConfig } from 'unocss';

export default defineConfig({
  ...getDesignSystemContentPathConfig('vue'),
  presets: [presetAlephAlpha()],
});

After (3 lines):

import { defineAppConfig } from '@aleph-alpha/config-unocss';

export default defineAppConfig();

Apps with their own brand colors keep them via the theme option. Colors you list here are deep-merged on top of the design-system tokens — only the keys you set are overridden, the rest of the token palette stays available:

import { defineAppConfig } from '@aleph-alpha/config-unocss';

export default defineAppConfig({
  theme: {
    colors: {
      'brand-bg-brand': '#CCE804',
      'core-bg-accent': '#555CF9',
    },
  },
});

Apps that pulled in extra UnoCSS presets (e.g. presetTypography) or transformers (e.g. transformerDirectives for @apply) layer them on via presets and transformers:

import { defineAppConfig } from '@aleph-alpha/config-unocss';
import { presetAlephAlphaIcons } from '@aleph-alpha/ds-icons';
import { presetTypography, transformerDirectives } from 'unocss';

export default defineAppConfig({
  presets: [presetAlephAlphaIcons(), presetTypography()],
  theme: {
    breakpoints: { xs: '480px', sm: '640px', md: '768px', lg: '1024px' },
    colors: { 'brand-bg-brand': '#CCE804' },
  },
  transformers: [transformerDirectives()],
});

Apps that wrapped theme overrides in their own preset (definePreset) keep that pattern unchanged — defineAppConfig accepts any UnoCSS preset alongside the defaults:

import { defineAppConfig } from '@aleph-alpha/config-unocss';
import { presetAlephAlphaIcons } from '@aleph-alpha/ds-icons';
import { definePreset } from 'unocss';

const presetMyAppTheme = definePreset(() => ({
  name: 'my-app-theme',
  theme: { colors: { 'core-bg-primary': '#FBFBFD' } },
}));

export default defineAppConfig({
  presets: [presetAlephAlphaIcons(), presetMyAppTheme()],
});

Apps with local workarounds (e.g. token-specific alpha-hex fixes, spacing-preset shims for older ds-components-vue versions) keep them local and inject via presets or rules:

import { defineAppConfig } from '@aleph-alpha/config-unocss';
import { alphaFixRules } from './local-alpha-fix';

export default defineAppConfig({
  rules: alphaFixRules,
});

ℹ️ Legacy presetAlephAlpha() (singular) is not re-exported — switch to defineAppConfig() as shown above. If you need the raw preset stack for a custom defineConfig, use the plural presetsAlephAlpha() (see Composing manually).

Exports

  • defineAppConfig(options?) — app-oriented defineConfig wrapper, bundles presetsAlephAlpha() + design-system content paths.
  • presetsAlephAlpha() — full preset stack (Wind, Typography, web fonts, animations, tokens, theme, legacy compat).
  • tokenPreset — only the design-system token preset (CSS variables, theme mapping).
  • commonPresets — Wind + Typography + web fonts + animations, without tokens.
  • createPresets() — token preset + dark-mode theme preset + legacy compat preset.
  • getDesignSystemContentPathConfig(framework) — content pipeline config for scanning @aleph-alpha/ds-components-vue or -svelte.
  • Theme — TypeScript theme type derived from the design tokens.
  • AppConfigOptions — TypeScript options type for defineAppConfig.
  • presetWebFontsAlephAlpha — embedded @font-face rules for Raleway, Roboto, Montserrat, Inter.

版本与发布记录

@aleph-alpha/config-unocss 共发布 2 个版本,首次发布于 2026/06/18;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.2.1latest2026/08/102 个月前
0.2.02026/06/184 个月前

关于 @aleph-alpha/config-unocss 的常见问题

@aleph-alpha/config-unocss 是什么?

Shared UnoCSS presets for Aleph Alpha frontends. Re-exports the design-system token preset, web fonts preset, and helpers.

如何安装 @aleph-alpha/config-unocss?

在项目目录运行 npm install @aleph-alpha/config-unocss,或使用 pnpm add / yarn add / bun add。

@aleph-alpha/config-unocss 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aleph-alpha/config-unocss 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@aleph-alpha/config-unocss 可以商用吗?

@aleph-alpha/config-unocss 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aleph-alpha/config-unocss 的下载量有多少?

根据 npm 官方下载统计,@aleph-alpha/config-unocss 在 2026/10/06 – 2026/11/04 这 30 天内被下载 14,291 次,日均约 476 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aleph-alpha/config-unocss 还在维护吗?

最新版本 0.2.1 发布于 2026/08/10(2 个月前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/06/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。