1

react-native cli 的 Metro 捆绑器无法解析.vrx文件(用于 virreact AR 场景)。

我试图在项目根目录中创建一个 rn-cli.config.js 文件,该文件应该对其进行排序,但事实并非如此。我错过了什么?

我试图在项目根目录中创建一个 rn-cli.config.js 文件,该文件应该对其进行排序,但事实并非如此。我错过了什么?

在要求的 .js 中指定的路径绝对正确

rn-cli.config.js

const { getDefaultConfig } = require("metro-config");

module.exports = (async () => {
  const {
    resolver: { assetExts }
  } = await getDefaultConfig();

  return {
    resolver: {
      assetExts: [...assetExts, "obj", "mtl", "JPG", "vrx", "fbx", "hdr"]
    }
  };
})();

Metro bundler 报告此错误

error: bundling failed: Error: Unable to resolve module `./js/res/coffee_mug/object_coffee_mug.vrx` from `C:\Users\Dave\Documents\schoolOfCode\Final Project\final-project-app-brumgo-front-end\components\ARtest\index.js`: The module `./js/res/coffee_mug/object_coffee_mug.vrx` could not be found from `C:\Users\Dave\Documents\schoolOfCode\Final Project\final-project-app-brumgo-front-end\components\ARtest\index.js`. Indeed, none of these files exist:
4

1 回答 1

0

请更新项目根目录下的 metro.config.js,如下所示。

const {getDefaultConfig} = require('metro-config');

module.exports = (async () => {
  const {
    resolver: {assetExts},
  } = await getDefaultConfig();

  return {
    resolver: {
      assetExts: [
        ...assetExts,
        'obj',
        'mtl',
        'JPG',
        'vrx',
        'hdr',
        'gltf',
        'glb',
        'bin',
        'arobject',
        'gif',
      ],
    },
  };
})();
于 2020-07-30T23:11:09.493 回答