expo-asset
Version:
An Expo universal module to download assets and pass them into other APIs
29 lines (20 loc) • 784 B
text/typescript
import { type ConfigPlugin, createRunOncePlugin } from 'expo/config-plugins';
import { withAssetsAndroid } from './withAssetsAndroid';
import { withAssetsIos } from './withAssetsIos';
const pkg = require('../../package.json');
export type AssetProps = {
/** An array of asset files or directories to link to the native project, relative to the project root. */
assets?: string[];
};
const withAssets: ConfigPlugin<AssetProps | null> = (config, props) => {
if (!props) {
return config;
}
if (props.assets && props.assets.length === 0) {
return config;
}
config = withAssetsIos(config, props.assets ?? []);
config = withAssetsAndroid(config, props.assets ?? []);
return config;
};
export default createRunOncePlugin(withAssets, pkg.name, pkg.version);