gpt4 book ai didi

javascript - Expo - React Native - Metro 配置文件

转载 作者:行者123 更新时间:2023-12-05 01:23:22 33 4
gpt4 key购买 nike

我正在使用 React Native 和 Expo CLI 构建应用程序。一旦应用程序构建并在试飞中进行测试,我就会遇到缺少 Assets 的问题。我收到以下错误。我已经阅读了关于 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.

应用程序.json

{
"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"
}
}
}

metro.config.js

const { getDefaultConfig } = require('expo/metro-config');
module.exports = (async () => {
const {
resolver: { sourceExts, assetExts },
} = await getDefaultConfig(__dirname);
return {
resolver: {
assetExts: [
...assetExts,
'png',
'jpg',
'jpeg',
'gif',
'svg',
'ttf',
'otf',
'woff',
'woff2',
],
sourceExts: [
...sourceExts,
'cjs',
'jsx',
'ts',
'tsx',
'mjs',
'md',
'mdx',
],
},
};
})();

最佳答案

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

 transformer: {
assetPlugins: ['expo-asset/tools/hashAssetFiles'],
},

关于javascript - Expo - React Native - Metro 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72469850/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com