Extend ReactNative extensions for a specific platform?

Can I connect to specific React-Native platform extensions to use custom ones?

In the same way, you can diverge .ios.jsand .android.jsis there a way to define custom extensions .xyz.js. (Equivalent to resol.extensions web package )

+7
source share
1 answer

You can override the original configuration rn-cli.config.jsin rn-cli.config.jsthe root of the project as follows:

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

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

  return {
    resolver: {
      sourceExts: ['xyz.js', ...sourceExts]
    }
  }
})()

sourceExt platforms sourceExt, , , ( , ios 'android, RN ).

sourceExts , , ['js', 'json', 'ts', 'tsx']. ['xyz.js', 'js', 'json', 'ts', 'tsx'], RN *.xyz.js *.xyz.js, .

0

Source: https://habr.com/ru/post/1678871/


All Articles