Skip to content

Commit

Permalink
[docs] Add config plugin info in Expo Asset (expo#28261)
Browse files Browse the repository at this point in the history
# Why

<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

Fixes ENG-11786

# How

<!--
How did you build this feature or fix this bug and why?
-->

By documenting the config plugin example and properties in Expo Asset
API reference. Changes applied to unversioned reference.

# Test Plan

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

Run docs locally and visit:
http://localhost:3002/versions/unversioned/sdk/asset/#configuration-in-appjsonappconfigjs

## Preview

![CleanShot 2024-04-17 at 23 05
11@2x](https://github.com/expo/expo/assets/10234615/3bb6bccf-3d6a-490e-8ad2-b776b41bf706)


# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [x] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [x] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
  • Loading branch information
amandeepmittal authored Apr 24, 2024
1 parent e58ee86 commit 8e346b5
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion docs/pages/versions/unversioned/sdk/asset.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,56 @@ platforms: ['android', 'ios', 'tvos', 'web']
import APISection from '~/components/plugins/APISection';
import { APIInstallSection } from '~/components/plugins/InstallSection';
import PlatformsSection from '~/components/plugins/PlatformsSection';
import { ConfigPluginExample, ConfigPluginProperties } from '~/components/plugins/ConfigSection';

**`expo-asset`** provides an interface to Expo's asset system. An asset is any file that lives alongside the source code of your app that the app needs at runtime. Examples include images, fonts, and sounds. Expo's asset system integrates with React Native's, so that you can refer to files with `require('path/to/file')`. This is how you refer to static image files in React Native for use in an `Image` component, for example. Check out React Native's [documentation on static image resources](https://reactnative.dev/docs/images#static-image-resources) for more information. This method of referring to static image resources works out of the box with Expo.
`expo-asset` provides an interface to Expo's asset system. An asset is any file that lives alongside the source code of your app that the app needs at runtime. Examples include images, fonts, and sounds. Expo's asset system integrates with React Native's, so that you can refer to files with `require('path/to/file')`. This is how you refer to static image files in React Native for use in an `Image` component, for example. Check out React Native's [documentation on static image resources](https://reactnative.dev/docs/images#static-image-resources) for more information. This method of referring to static image resources works out of the box with Expo.

## Installation

<APIInstallSection />

## Configuration in app.json/app.config.js

You can configure `expo-asset` using its built-in [config plugin](/config-plugins/introduction/) if you use config plugins in your project ([EAS Build](/build/introduction) or `npx expo run:[android|ios]`). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect.

<ConfigPluginExample>

```json app.json
{
"expo": {
"plugins": [
[
"expo-asset",
{
"assets": ["path/to/file.png", "path/to/directory"]
}
]
]
}
}
```

</ConfigPluginExample>

<ConfigPluginProperties
properties={[
{
name: 'assets',
description: [
'An array of asset files or directories to link to the native project. The paths should be relative to the project root so that the file names, whether specified directly or using a directory, will become the resource names.',
'',
'Supported file types:',
'* Images: `.png`, `.jpg`, `.gif`',
'* Media: `.mp4`, `.mp3`, `.lottie`',
'* SQLite database files: `.db`',
'',
'> **Note**: To import an existing database file (`.db`), see instructions in [SQLite API reference](/versions/latest/sdk/sqlite/#import-an-existing-database). For other file types such as `.lottie`, see [how to add a file extension to `assetExts` in metro config](/guides/customizing-metro/#adding-more-file-extensions-to-assetexts)',
].join('\n'),
default: '[]',
},
]}
/>

## API

```js
Expand Down

0 comments on commit 8e346b5

Please sign in to comment.