Compress the assets in your project
This library uses the natively powered package Sharp behind the scenes to optimally reduce your project's assets for use in an app or website.
👋 Notice: This package is not limited to Expo projects! This can be used with projects bootstrapped with community CLIs like ignite by Infinite Red, or react-native-cli by the React Native community.
# Run this once to install the sharp image processing utility.
# If this cannot be installed on your computer then you won't be able to optimize images.
npm install -g sharp-cli
# To optimize images simply run this
npx expo-optimize <project-directory> [options]
We created optimize
to improve our docs and websites (Next, Gatsby, React), and our native apps (React & Expo). Optimizing images can noticeable improve your native app and website's TTI (or time-to-interaction) which means less time on splash screens and quicker delivery over poor network connections.
For more information run npx expo-optimize --help
(or -h
)
Shortcut | Flag | Input | Description | Default |
---|---|---|---|---|
-q |
--quality |
[number] |
The quality each image will attempt to be reduced to | 80 |
-i |
--include |
[pattern] |
Include only assets that match this glob pattern relative to the project root | expo.assetBundlePatterns: [] in the app.json |
-e |
--exclude |
[pattern] |
Exclude all assets that match this glob pattern relative to the project root | '**/node_modules/**', '**/ios/**', '**/android/**' |
-s |
--save |
Save the original assets with a .orig extension | ||
-h |
--help |
output usage information | ||
-V |
--version |
output the version number |
Read more about how this package works here: Image compression in Expo projects.
The Expo source code is made available under the MIT license. Some of the dependencies are licensed differently, with the BSD license, for example.