Expo - React Native - Metro 配置文件

Log*_*lio 6 javascript mobile react-native expo

我正在使用 React Native 并使用 Expo CLI 构建一个应用程序。一旦应用程序构建并在试飞中进行测试,我就会遇到资产丢失的问题。我收到以下错误。我已经阅读了有关 React Native 和 Expo 的文档,但似乎无法找出问题所在。还附上了我的 app.json 和 Metro.config.js 文件。

It looks like that you are using a custom metro.config.js that does not extend @expo/metro-config.
This can result in unexpected and hard to debug issues, like missing assets in the production bundle.
We recommend you to abort, fix the metro.config.js, and try again.
Run Code Online (Sandbox Code Playgroud)

应用程序.json

It looks like that you are using a custom metro.config.js that does not extend @expo/metro-config.
This can result in unexpected and hard to debug issues, like missing assets in the production bundle.
We recommend you to abort, fix the metro.config.js, and try again.
Run Code Online (Sandbox Code Playgroud)

地铁配置.js

{
  "expo": {
    "name": "Unfiltered",
    "slug": "unfiltered-with-kiran",
    "version": "1.0.5",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "blahblahblah",
      "buildNumber": "1"
    },
    "android": {
      "versionCode": 2,
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "blahblahblah"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

Log*_*lio 12

我终于找到了答案,我必须添加变压器和assetPlugins。

 transformer: {
      assetPlugins: ['expo-asset/tools/hashAssetFiles'],
    },
Run Code Online (Sandbox Code Playgroud)