Last active
July 11, 2019 23:15
-
-
Save shrey18111/050c379f28e64e2397aabf6a15a77f17 to your computer and use it in GitHub Desktop.
Metro setup for importing assets from parent directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let path = require("path") | |
module.exports = { | |
getTransformModulePath() { | |
return require.resolve("react-native-typescript-transformer") | |
}, | |
sourceExts: ["ts", "tsx"], | |
// Set projectRoot to the web front-end root (Realization 1 above) | |
projectRoot: path.resolve(__dirname, "../assets/javascripts"), | |
// Set watchFolders to include the current directory, parent node_modules | |
// and the mobile node_modules (Realization 2 above) | |
watchFolders: [ | |
path.resolve(__dirname), | |
path.resolve(__dirname, "./node_modules"), | |
path.resolve(__dirname, "../node_modules"), | |
], | |
resolver: { | |
// Set extraNodeModules to include the directories that you want to import | |
// files from (in our case, we wanted to import files specifically from | |
// util and types) | |
extraNodeModules: { | |
util: path.resolve(__dirname, "../assets/javascripts/util"), | |
types: path.resolve(__dirname, "../assets/javascripts/types"), | |
}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment