有没有办法让react-native忽略一些不捆绑它们的文件?

zsx*_*zsx 6 android react-native

我已经有一个基于 React for Web 的项目。现在,我在这里创建了一个 React-Native 项目。如果我与 捆绑react-native bundle,react-native 将捆绑我的所有文件,然后提示大量警告。所以我想让react-native忽略/www.

我尝试了这些操作,但没有用:

  1. 将我的路径添加到sharedBlacklistWildcardsin中node_modules/react-native/packager/blacklist.js
  2. 将我的路径添加到.flowconfig.

我检查了文档,但没有发现任何有用的东西。我怎么能这样做,或者我的想法是错误的?

zsx*_*zsx 1

嗯,我修改了node_modules/react-native. 这是我迄今为止找到的唯一方法,我仍然期待更好的解决方案。

node_modules\react-native\packager\react-packager\src\DependencyResolver\fastfs.js用于扫描文件。所以我重写File::getFiles了这个:

  getFiles() {
    return _.flatten(_.values(this.children).filter(
        file => !/platforms$|www$/.test(file.path)
      ).map(file => {
        if (file.isDir) {
          return file.getFiles();
        } else {
          return file;
        }
    }));
  }
Run Code Online (Sandbox Code Playgroud)