@18f/identity-build-sass

中文文档
3.2.0发布于 2026/08/05CC0-1.0ES Module近 30 天下载 2141

Stylesheet compilation utility with reasonable defaults and fast performance.

原始使用文档
文档目录4 节
  1. Usage
  2. CLI
  3. API
  4. License

@18f/identity-build-sass

Stylesheet compilation utility with reasonable defaults and fast performance.

Why use it?

  • ⚡️ It's fast, since it uses native Dart Sass binary through sass-embedded, and the Rust-based Lightning CSS for autoprefixing and minification.
  • 💻 It includes a CLI, so it's easy to integrate with command-based build pipelines like NPM scripts or Makefile.
  • 🚀 It has relevant defaults, to work out of the box with minimal or no additional configuration.

Default behavior includes:

  • Optimizations enabled based on the NODE_ENV environment variable.
  • Autoprefixer configuration based on the current project's Browserslist configuration.
  • Automatically adds node_modules as a loaded path for Sass compilation.
  • Output filenames derived from the input filenames (main.css.scss becomes main.css).
  • Automatically adds required load paths for @18f/identity-design-system and @uswds/uswds.

Usage

CLI

Invoke the included build-sass executable with the source files and any relevant command flags.

npx build-sass path/to/sass/*.scss

Flags:

  • --out-dir: The output directory
  • --watch: Run in watch mode, recompiling files on change
  • --load-path: Include additional path in Sass path resolution
  • --verbose (-v): Output verbose debugging details

API

buildFile

Compiles a given Sass file.

function buildFile(
  file: string,
  options: {
    outDir: string,
    optimize: boolean,
    sassCompiler: SassAsyncCompiler,
    ...sassOptions: SassOptions<'sync'>,
  },
): Promise<SassCompileResult>;

License

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request or issue, you are agreeing to comply with this waiver of copyright interest.

版本与发布记录

@18f/identity-build-sass 共发布 8 个版本,首次发布于 2022/11/22;过去 12 个月发布了 1 个版本。

版本发布日期距今
3.2.0latest2026/08/053 个月前
3.1.02024/04/252 年前
3.0.02024/01/292 年前
2.0.02023/10/163 年前
1.3.02023/05/183 年前
1.2.02023/05/083 年前

关于 @18f/identity-build-sass 的常见问题

@18f/identity-build-sass 是什么?

Stylesheet compilation utility with reasonable defaults and fast performance.

如何安装 @18f/identity-build-sass?

在项目目录运行 npm install @18f/identity-build-sass,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 build-sass,可以用 npx build-sass 直接运行。

@18f/identity-build-sass 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/18f__identity-build-sass 是否存在。

@18f/identity-build-sass 支持 ESM 还是 CommonJS?

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

@18f/identity-build-sass 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@18f/identity-build-sass 可以商用吗?

@18f/identity-build-sass 使用 CC0-1.0 许可。作者放弃著作权,可不受限制地使用。以上为概括,不构成法律意见,请以许可原文为准。

@18f/identity-build-sass 的下载量有多少?

根据 npm 官方下载统计,@18f/identity-build-sass 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,141 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@18f/identity-build-sass 还在维护吗?

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