zsx
zsx

Reputation: 111

Is there a way to make react-native ignore some files that not to bundle them?

I already had a project which based on React for Web. And now, I created a React-Native project here. If I bundle with react-native bundle, react-native will bundle all my files then prompt lots of WARNING. So I want to make react-native ignore files under /www.

I tried these actions, but useless:

  1. Add my paths to sharedBlacklistWildcards in node_modules/react-native/packager/blacklist.js.
  2. Add my paths to .flowconfig.

I checked the documentation, but didn't find anything useful. How could I do that, or if I have a wrong idea?

Upvotes: 6

Views: 1725

Answers (1)

zsx
zsx

Reputation: 111

Well, I modified the file in the node_modules/react-native. It's the only way I found so far, and I'm still looking forward to a better solution.

node_modules\react-native\packager\react-packager\src\DependencyResolver\fastfs.js is used to scan files. So I rewrited File::getFiles to this:

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

Upvotes: 1

Related Questions