如何使用rn-cli.config启用'require(* / *。vrx)'?

时间:2019-05-17 12:02:54

标签: react-native augmented-reality metro-bundler viro-react

用于原生cli的Metro捆绑程序无法解析 .vrx 文件(用于虚拟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"]
    }
  };
})();

地铁捆绑器报告此错误

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:

1 个答案:

答案 0 :(得分: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',
      ],
    },
  };
})();