Skip to main contentSkip to docs navigation

Chassis

Build System

View on GitHub

The chassis-icons command and its steps, the settings of chassis.build, how code points are kept, the checks, and taking a newer build into a set.

Introduction

The build is the chassis-icons command of @chassis-ui/icons, a development dependency of a repository of icons. It turns the SVG files of source/ into the output of the set, step by step, and reads one block of configuration: the same build writes the set of any team, and names no set itself.

The output, dist/, is not committed: a build writes it from source/, codepoints.json and the version of the builder, and the release of the set builds it again. The build also writes codepoints.json, README.md and fields of package.json, which the repository commits. After a change to source/ or to the configuration, run the build and commit those files with the change.

Prerequisites

The build needs a repository of icons, which chassis-icons init writes, with Node.js 22.12 or later and npm or pnpm. The quick start makes one. The scripts of its package.json run the command: npm run build is chassis-icons build, npm run lint is chassis-icons lint-source, npm run preview is chassis-icons preview --serve, and verify, archive and release-notes are the commands of the same name. This page names the command itself, which npx runs from the installed package; when a script runs it, an option goes after --, as in npm run build -- --only font.

Commands

chassis-icons build writes the whole output, and the other commands check a set, show it, package it and start one.

CommandWhat it does
buildWrites dist/, which is not committed, and codepoints.json, README.md and the fields of package.json that name the files of the output, which are
build --only <step>One step: svgs, sprite, font, ios, android or package
build --dry-runLists the files that a build would change, dist/ among them, and changes none
verifyChecks that the source builds, twice to the same files, that codepoints.json, README.md and package.json are up to date, that no icon lost its code point, and that the icons of the checks file are there
verify --since <ref>Compares the code points with those of a commit, a branch or a tag, in place of the last tag
lint-sourceChecks the files of source/: names, frame, color, pairs
previewWrites the page of the set into preview/, from the output in dist/
preview --serveWrites the page and serves it at http://localhost:4325/ until stopped; --port <n> serves it at another port, 0 at any free one
archiveWrites the archives of a release into archives/: <font>-web-<version>.zip, with icons.json, svgs/, web/ and preview/ in it, and <font>-<target>-<version>.zip of each target; --to <dir> writes them to another folder
release-notes [version]Prints the entry of a version in CHANGELOG.md, that of package.json by default, and fails without one
init [dir]Writes the files of a new repository of icons

Every command but init works on one repository of icons: --cwd <dir> names it, and by default it is the nearest folder upward from the working directory whose package.json has a chassis block, so the command runs from any folder of the repository. --verbose names each file that is written and each code point that is given or retired, and --help prints every command and option:

Shell
npx chassis-icons --help
npx chassis-icons init --help

init

chassis-icons init [dir] writes into a folder, the working directory by default, package.json with the chassis.build block, the scripts and the dependency on the builder, .gitignore, .nvmrc, CHANGELOG.md, AGENTS.md, CLAUDE.md, and the workflows .github/workflows/ci.yml and .github/workflows/release.yml. It writes nothing into source/ and no README: the build writes the README. When a file that it would write exists, it writes nothing, unless --force writes over the others; package.json and CHANGELOG.md are never written over.

OptionDefaultWhat it sets
--name <name>The name of the folderThe name of the package
--font <name>The name of the folder, in kebab-caseThe name of the font, chassis.build.name
--prefix <name>The first letter of each part of the font nameThe class prefix, chassis.build.prefix
--pm <npm|pnpm>npmThe package manager that the workflows and the instructions name
--repository <repo>The origin remote of the folder, or left outThe repository, as owner/name or an address
--license <license>MITThe license
--author <author>user.name of Git, or left outThe author
--only <file…>Every fileWrites these files only, for a repository made earlier; one that exists needs --force
--checkReports where the repository differs from what this version writes, and exits with 1 when it does. Writes nothing
--forceWrites over the files that exist, but never package.json or CHANGELOG.md
--dry-runPrints the files, and writes nothing

--check reads the package manager from the lockfile of the repository, so before the first install, give --pm with it.

Steps

The build has these steps, and each reads what the step before it wrote. ios and android run when chassis.build.targets names them.

StepReadsWrites
svgssource/dist/svgs/<name>.svg, optimized with SVGO, and removes a file whose source is gone
spritedist/svgs/dist/web/<font>.svg, built with svg-sprite
fontdist/svgs/ and codepoints.jsonThe font in each format, built with Fantasticon, dist/web/<font>.css, .min.css, .scss and .json, dist/icons.json, the index of the set, and codepoints.json
iosdist/svgs/dist/ios/<module>.xcassets, an asset catalog with an image set per icon, and dist/ios/<module>.swift, the enum of the icons
androiddist/svgs/dist/android/res/drawable/<prefix>_<name>.xml, a vector drawable per icon, converted with svg2vectordrawable
packageThe configurationThe fields of package.json that name the files, and README.md

<module> is the font name in PascalCase: acme-icons gives AcmeIcons. The ios and android steps empty their folder and write it again. A whole build removes from dist/svgs/ each file whose source is gone, and from dist/ and dist/web/ each file that it did not write, such as the files of another font name, or the folder of a target that the configuration no longer names. build --only ios stops when targets does not name ios, and so does build --only android. The steps after svgs read dist/svgs/, so build --only sprite and build --only font build from the files that are there.

The build optimizes, and draws nothing. It does not resize or recolor an icon, and it does not outline a stroke: the source lint refuses a file that the build cannot use.

Output

dist/ is the output of the set: the build writes it, .gitignore keeps it out of the commits, the release builds it again, and files of package.json publishes the files of the web. What every target reads is at its top, and the files of the web and of each target of the configuration are in a folder of their own.

TEXT
dist/
  icons.json                                -> The index of the set
  svgs/<name>.svg                           -> One optimized SVG file per icon
  web/<font>.css                            -> The stylesheet of the font, with .min.css and .scss beside it
  web/<font>.woff2                          -> The font, in each format of the configuration
  web/<font>.svg                            -> The sprite
  web/<font>.json                           -> The code point of each icon, by name, as a number
  ios/<module>.xcassets/                    -> With the ios target: an image set per icon, <name>.imageset
  ios/<module>.swift                        -> With the ios target: the enum of the icons
  android/res/drawable/<prefix>_<name>.xml  -> With the android target: a vector drawable per icon

The package on npm holds icons.json, svgs/ and web/. The files of ios/ and android/ are not in it: the release attaches them to its GitHub release as archives, and iOS and Android shows how an app uses them.

dist/icons.json is the index of the set: name, prefix, frame, styles and pairs of the configuration, and under icons one entry per icon with its name and its codepoint in four hex digits, and its base and style when the set has styles. It names no version, so a release that changes no icon changes no line of it. The page of the set reads it. An entry of icons has this shape, with the code point that codepoints.json gives the icon:

JSON
{"name":"<name>","codepoint":"f101","base":"<base>","style":"<style>"}

Page of the set

chassis-icons preview writes the page of the set into preview/ from dist/: index.html, its stylesheet and its script, and copies of the files of dist/web/ and dist/svgs/. The page is not output: .gitignore keeps it out of the commits, files does not publish it, and verify does not check it. The archive of a release holds it.

Shell
npm run preview

The script runs chassis-icons preview --serve, which serves the page at http://localhost:4325/ until you stop it with Ctrl+C. The page shows every icon with its name, a search box, a filter of the styles and a switch of the theme, and on a click a drawer with the icon at size, examples of it in Chassis components, its class, its code point and the code that draws it. #<name> in the address opens the drawer of that icon. The page is drawn with Chassis CSS, which it loads from jsDelivr. Served from a folder, it draws the icons from the sprite beside it; opened from the file system, where a browser does not read the sprite, it draws them with the font and says so.

Configuration

The configuration of a set is the chassis.build block of the package.json at the root of its repository, with the checks file beside it.

chassis.build

The build reads the chassis.build block. A setting that the block leaves out has its default, and a setting that the build does not know stops it with a message that names the setting.

SettingDefaultWhat it sets
namerequiredThe name of the font, and of every file of dist/web/
prefixrequiredWhat a class starts with: <prefix>-<name>
source"source"The folder of the SVG files, from the root of the repository
checks"chassis.checks.json"The checks file, from the root of the repository. It may not exist
frame24The width and the height of the frame an icon is drawn on
styles[]The last part a name may have. Any kebab-case name when empty
pairs[]The styles an icon comes in together
startCodepoint"f101"The code point of the first icon of a new set, in the Private Use Area, e000 to f8ff
formats["woff2", "woff"]The font formats, in the order of the src of the font face: woff2, woff, ttf
ligaturesfalseWith true, the font draws an icon for its name, in an element of the class <prefix>
header[]The lines of the comment at the top of each stylesheet. {version} is the version of the package
targets[]The targets besides the web, which is always built: ios, android

name and prefix are kebab-case names. init writes the block with every setting but targets, so that the defaults are in view. For the font acme-icons and the author Acme:

JSON
{
  "chassis": {
    "build": {
      "name": "acme-icons",
      "prefix": "ai",
      "frame": 24,
      "styles": [],
      "pairs": [],
      "startCodepoint": "f101",
      "formats": ["woff2", "woff"],
      "ligatures": false,
      "header": ["Acme Icons v{version}", "Copyright Acme", "Licensed under MIT"]
    }
  }
}

A set of the team Acme, @acme/glyphs, has the frame 16, the styles line and fill, and the pair of line and fill: a name of that set ends in a style, and an icon that has a line file has a fill file too. Names and styles describes both settings. That set also has the targets ios and android.

Package fields

The other fields of package.json describe the package. init writes name, version, description, repository, license, author, publishConfig, the scripts and the dependency on the builder, and from then on they are yours, private and homepage among them. The build writes main, style, sass, files, exports and sideEffects, which name the files of the font, and keeps an entry of files or exports that is not about dist/, such as the CHANGELOG.md that init lists. An entry about icons/ or svgs/, where an earlier build wrote the output, is removed. files names the output for the web only, and npm packs it although .gitignore names dist/. For the font acme-icons, with exports left out here:

JSON
{
  "main": "dist/web/acme-icons.css",
  "style": "dist/web/acme-icons.css",
  "sass": "dist/web/acme-icons.scss",
  "files": ["dist/icons.json", "dist/svgs", "dist/web", "CHANGELOG.md"],
  "sideEffects": ["*.css", "*.scss"]
}

Publishing says what the release workflow reads of the fields that are yours.

Checks file

chassis.checks.json lists, under contracts, the icons that a consumer reads by name. Each entry has a reader, which the message of a failed check names, and its icons. The build does not read the file, verify does, and a set without the file passes.

JSON
{
  "contracts": [{ "reader": "the toolbar of the app", "icons": ["bar-fill", "ring-line"] }]
}

The README

The build writes README.md at the root of the repository, for someone who installs the set: the package and what it holds, the code of the font class, the sprite, an SVG file and Sass with the font name and the prefix of the set, a section for iOS and one for Android when the set has those targets, and a section on the source, which names npm run build, npm run lint and npm run verify when package.json has the scripts of init, and the pnpm commands when pnpm-lock.yaml is beside it. description, homepage, repository and license of package.json are shown in it. Never change the file by hand: the next build writes it again.

Templates

The stylesheets, the README and the page of the set are written from the Handlebars templates of the builder, css.hbs, scss.hbs, readme.hbs and preview/index.hbs in node_modules/@chassis-ui/icons/lib/templates/. They are the same for every set, so a change to what the build writes for every icon is a change to the builder, proposed in its repository and taken into a set with a newer version.

Code points

An icon keeps its code point for as long as it is in the set, so a stylesheet that a browser has cached draws the right icon after another is added. codepoints.json, at the root of the repository, is the registry of the code points, and the build is its only writer.

JSON
{
  "icons": { "<name>": "f101" },
  "retired": ["f243"]
}

A new icon gets the first code point, from startCodepoint, that no icon has or had, and never moves another. The code point of a removed icon is retired: no later icon gets it. build --verbose names each code point that a build gives or retires. The registry is the state of the build, so commit it with the change to source/.

dist/web/<font>.json is output for a consumer: the same code points as numbers, without the retired ones. dist/icons.json has them too, as hex digits.

Checks

Two commands check a set. lint-source checks the files of source/ before a build, and verify checks what the build makes of them. The CI workflow that init wrote runs release-notes, lint-source and verify on a pull request and on a push to main.

Shell
npx chassis-icons lint-source
npx chassis-icons verify

verify builds the set twice into temporary folders, and fails when a file of dist/ differs between the two builds, when codepoints.json, README.md or package.json is not what the source builds, when an icon lost the code point that codepoints.json gave it at the last tag, when two icons share a code point, or when an icon of the checks file is missing. It does not read dist/ of the repository, so it passes with or without a build there. verify --since <ref> compares the code points with those of a commit, a branch or a tag, in place of the last tag.

Taking a newer build

A new version of the builder reaches a repository of icons through its development dependency, and the files that init wrote are the repository's from then on. Raise the version of @chassis-ui/icons in devDependencies of package.json, install, and see what changes: a newer build can write other files for the same source, and a change to the output is a change to the package of the set, which the changelog entry of its next version says. dist/ is not committed, so build --dry-run, before the build, lists the files that the newer build writes differently from the dist/ of the last build, and git diff shows what changed in the files that are committed.

Shell
npm install
npm run build -- --dry-run
npm run build
git diff --stat

A newer version of init may write other workflows or instructions. init --check reports which of its files differ from what the installed version writes, and init --only <file…> --force writes them again; a repository may differ on purpose, so read the diff before you commit:

Shell
npx chassis-icons init --check
npx chassis-icons init --only .github/workflows/ci.yml .github/workflows/release.yml --force

The changelog of the builder names what each version changes in the output and in the files of init.

Troubleshooting

Each entry gives the message or the symptom, then the cause and the fix.

Unknown setting

The build stops with Unknown setting in "chassis.build": <setting>. The block holds a key that the build does not read, such as a misspelled one. Remove it, or correct its name from the table of chassis.build.

No package.json

The command stops with There is no package.json in <dir>. No folder upward from the working directory has a package.json with a chassis block, so the command took the working directory. Run it inside the repository of icons, or name the repository with --cwd <dir>.

Committed file is stale

verify prints <file>: changed. It is not what the source builds: run the build, and commit it. for codepoints.json, README.md or package.json. A file of source/, the configuration or the builder changed, and the committed file is older. Run build, and commit the file with the change.

Build is not reproducible

verify prints <file> differs between two builds: the build is not reproducible. Two builds of the same source wrote that file of dist/ differently, so a release would not publish what the repository builds. It comes from the builder or a tool that it runs, not from the files of the set: report it in its repository with the name of the file.

Code points not compared

verify prints a note that starts with The code points were not compared with an earlier state. The repository has no tag yet, or the tag has no codepoints.json, and neither dist/web/<font>.json nor icons/<font>.json, where earlier builds wrote the code points. It is a note and not a problem: the comparison starts with the first release of the set.

Repository differs

init --check prints <file>: differs and exits with 1. The file was changed in the repository, or the installed version of init writes it differently. Read the diff: keep the file when the repository differs on purpose, or write it again with init --only <file> --force.

Next steps

Continue with one of these pages:

  • Source lint: what lint-source checks, and its messages.
  • Publishing: from a built set to a package and a release.
  • The architecture document of the builder: the modules of the build, and the contract of each file of the output.