Where a designer puts an exported file, how to name it, which formats each platform gets, and how the change reaches the repository.
Introduction
This page is for the designer who exports a file and adds it to the repository. It covers the folder a file goes to, the name it gets, the formats each platform keeps, and the commit that brings it in.
You work in source/ only. The build writes the names, the formats and the folders of each platform from what you put there, and nothing under dist/ is edited by hand.
Prerequisites
You need Git and Git LFS. Fonts and raster images are Git LFS files: run git lfs install once on your machine before you clone, so that you get the files and not their pointers. A Git client with a window, such as GitHub Desktop, works as well as the command line.
To build the output and look at it before you commit, you also need Node.js and the package, see the quick start.
Source layout
Every file has a brand, an app and a type, and its path says all three.
source/
├── _default/ -> the default brand: files that every brand gets
│ ├── _shared/ -> files that every app gets
│ │ └── <type>/
│ └── <app>/ -> one folder per app
│ └── <type>/ -> fonts, images, icons, or any other folder
└── <brand>/ -> one folder per brand: only the files that differ
├── _shared/ -> files that every app of the brand gets
│ └── <type>/
└── <app>/
└── <type>/The brands and the apps are those of the chassis block of package.json. A folder that the configuration does not name is not read by the build, and the source lint warns about it. A name that starts with _ is no brand and no app: _default is the default brand, and _shared is the folder of a brand for the files of all its apps.
Overrides
A brand file replaces the default file of the same path, and the file of an app replaces the shared file of the same path. For each brand and app, the build takes the files of four folders, each over the one before:
source/_default/_shared/source/_default/<app>/source/<brand>/_shared/source/<brand>/<app>/
Add a file to a brand only when it differs from the default one. A logo that every brand shares belongs in source/_default/, once, and a brand with a logo of its own adds a file with the same subfolder and the same name to its folder. A file that every app of a brand uses, such as its fonts, belongs in _shared/ of the brand, once, rather than in the folder of each app.
Naming
A name in source/ is made of lowercase letters, digits and hyphens, with a lowercase extension. Each platform renames the file from there: the web keeps the hyphens, iOS and Android get underscores.
- Separate words with hyphens:
hero-background.jpg. - Name a file after what it shows or does:
illustration-onboarding.svg, notimage1.svg. - Put the color mode at the end of the name:
welcome-light.pngandwelcome-dark.png. - End a variant with its indicator:
hero-image.png,hero-image@2x.png,hero-image@3x.png. - Do not use spaces, capitals or underscores:
Hero Background.jpgandhero_background.jpgfail the source lint. - Do not put a dot or an indicator inside a name:
hero.v2.pngandhero@2x-final.pngfail the source lint. - Do not put the brand in the name: the folder says it, and a brand file has to have the name of the default file to replace it.
The source lint checks these rules on every pull request. Run it yourself with npx chassis-assets lint-source.
Formats
Export the formats of the platforms that the app is built for. The build leaves a format out where the platform does not use it, and does not convert one into another.
Fonts
Fonts go to fonts/, named by role, with their license beside them.
| Platform | Gets | Does not get |
|---|---|---|
| Web | WOFF2, WOFF, and the stylesheets of the folder | TTF, OTF |
| iOS | TTF, OTF | WOFF2, WOFF, stylesheets |
| Android | TTF, OTF | WOFF2, WOFF, stylesheets |
See fonts for the role names and the license files.
Images
Images go to images/, in any subfolders, with the variants an app needs.
| Platform | Gets | Does not get |
|---|---|---|
| Web | Every format | |
| iOS | Every format but WebP, with the indicator in the name | WebP |
| Android | Every format, in density folders |
See images for the variants and the density folders.
Icons
Export each icon as an SVG file into icons/ of the apps that show it, named after what it shows: arrow-right-solid.svg.
| Platform | Gets | Does not get |
|---|---|---|
| Web | Every file | |
| iOS | SVG, PDF, PNG | Every other format |
| Android | SVG, with the ic_ prefix | Every other format |
See icons for the formats and the names of each platform.
Other files
Any other folder under an app, such as videos/ or data/, is copied to every platform in every format. See other assets.
Adding a file
A change to the assets is a commit on a branch, reviewed in a pull request against the branch the repository releases from, main in the repository that chassis-assets init writes.
- Create a branch from
main. - Export the file from the design tool into its folder under
source/. - Run
npx chassis-assets lint-sourceto check the name, andnpx chassis-assets buildto see the file indist/. - Commit the files of
source/, and open a pull request againstmain. Say in the message which files the change adds todist/, removes from it or renames: the changelog entry of the next version names them.
git checkout -b feature/onboarding-assets main
npx chassis-assets lint-source
npx chassis-assets build
git add source/_default/site/images/onboarding.svg
git commit -m "feat: add the onboarding illustration"
git push origin feature/onboarding-assetsdist/ is not committed. Every consumer builds it from the source.
Best practices
These practices keep source/ to the files the build is meant to copy, and a commit to one change.
- Check the license before adding a font or a stock image: a font keeps its license beside it as
<role>-license.txt, such asui-license.txtorcode-license.txt. - Export every variant an app needs: the build copies
@2xand@3xfiles and does not make them. - Commit the exported file only: design sources, such as a
.figor a.sketchfile, do not belong insource/. Every file of a type folder is copied to the output. - Stage only the files of the change: a commit with unrelated exports is hard to review and to revert.
Avoid the habits that undo this:
- Do not copy a default file into a brand folder unchanged: the brand gets the default file anyway, and the copy has to be kept in step by hand.
Next steps
Continue with one of these pages:
- Fonts, images, icons and other assets: the rules of each type.
- Build system: the commands and what each one checks.
- The README of your repository of assets: its commands, its branches and its releases, as
chassis-assets initwrote them.