How the build copies any folder that is not fonts, images or icons, such as videos, audio, documents and data files.
Introduction
Any folder under an app is a type. fonts/, images/ and icons/ have rules of their own, and any other folder is copied to every platform as it is: every file, in its subfolders, with the name of the platform and no format filter. A bundle is the one exception.
The folder names on this page, videos/ and data/, are examples. An app may have a folder of any name for the files it needs: videos, audio, documents, data files.
Source layout
A folder of any name lives beside the three known types, in source/<brand>/<app>/. The default brand holds the files of every brand, and a brand holds only the files that differ.
source/
├── _default/
│ └── <app>/
│ ├── fonts/
│ ├── images/
│ ├── icons/
│ ├── videos/ -> any other folder
│ │ ├── onboarding-intro.mp4
│ │ └── tutorials/
│ │ └── step-1.webm
│ └── data/
│ └── country-list.json
└── <brand>/
└── <app>/
└── videos/
└── onboarding-intro.mp4 -> replaces the default file of the same pathThe folder follows the fallback of every type. A brand without the folder gets the files of the default brand, and a folder that only a brand holds, with no folder of the same name in the default brand, is in the output of that brand only. Two brands so do not have to hold the same files in such a folder, and an app reads a file only for the brands whose output has it.
Formats
The build copies a file of any format from such a folder to every platform of the app. The format rules of the known types do not apply: a WebP file in data/ reaches iOS, and a WOFF2 file reaches iOS and Android.
A file of a type that Git LFS tracks is stored as a Git LFS file wherever it is. A format that the repository does not track yet, such as MP4 or PDF, is committed as it is until .gitattributes names it:
git lfs track "*.mp4"Naming
Name a file in lowercase with hyphens, after what it holds: onboarding-intro.mp4, country-list.json. The build renames it for each platform, kebab-case for the web and snake_case for iOS and Android, as it does for every type.
Keep resolution variants under images/. In any other folder the Android output loses the indicator and gets no density folder, so poster.png and poster@2x.png end up with the same name. The build warns about the collision, and the file copied last wins.
Bundles
A folder that ends in .icon or .adaptive is a bundle, the app icon of an iOS or of an Android app. To the build it is one file, because the files in it name each other: the build copies it to the platform that takes it, renames the bundle to snake_case and leaves the names of the files in it alone. The source lint reads what each bundle holds.
source/<brand>/<app>/app-icon/app-icon.icon/ -> dist/ios/<app>/<brand>/app-icon/app_icon.icon/
source/<brand>/<app>/app-icon/app-icon.adaptive/ -> dist/android/<app>/<brand>/app-icon/app_icon.adaptive/A brand replaces a bundle whole, with a bundle of the same path. Keep a bundle in a folder of its own, such as app-icon/: under fonts/, images/ or icons/ it is an ordinary folder, which the source lint rejects. The app icons page has the files of each bundle, the rules of the lint and what the build writes with --vector-drawables and --res.
Adding files
Create the folder under the app, put the files in it, and run the build. No configuration names the folder.
mkdir -p source/_default/site/videos
cp onboarding-intro.mp4 source/_default/site/videos/
npx chassis-assets buildA brand replaces a file by adding one with the same path to its own folder, source/<brand>/<app>/videos/onboarding-intro.mp4. Subfolders are kept on every platform.
Best practices
The build copies a folder of another name as it is, so the name of the folder and the names of its files are what an app reads.
- Name the folder after its content:
videos/,audio/,documents/. The folder name is the folder name of the output, and an app reads its files from there. - Track large formats with Git LFS: add the extension to
.gitattributesbefore the first commit of such a file.
Avoid the habits that undo this:
- Do not use a folder of another name for fonts, images or icons: the format rules, the density folders and the
ic_prefix belong tofonts/,images/andicons/only. - Do not put a dot inside a name: the build turns it into the separator of the platform, so a file named
brand.tokens.jsonisbrand-tokens.jsonin the web output.
Platform output
The build copies each file to a folder of the same name in the job, in its subfolder, and renames it for the platform.
| Platform | Folder | Name | Formats |
|---|---|---|---|
| Web | dist/web/<app>/<brand>/<folder>/ | kebab-case, indicator kept | Every format |
| iOS | dist/ios/<app>/<brand>/<folder>/ | snake_case, indicator kept | Every format |
| Android | dist/android/<app>/<brand>/<folder>/ | snake_case, indicator removed | Every format |
For the source layout above, a web job gets the files under the names of the source:
dist/web/<app>/<brand>/
├── data/
│ └── country-list.json
└── videos/
├── onboarding-intro.mp4
└── tutorials/
└── step-1.webmAn iOS or an Android job gets them in snake_case:
dist/ios/<app>/<brand>/
├── data/
│ └── country_list.json
└── videos/
├── onboarding_intro.mp4
└── tutorials/
└── step_1.webmSee the web, iOS, and Android docs for how an app uses these files.