Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

I could not set module resolver for "assets" in typescript react-native?

$
0
0

npm i babel-plugin-module-resolver

this is babel.config.js

module.exports = function (api) {  api.cache(true);  return {    presets: ["babel-preset-expo"],    plugins: [      ["module-resolver",        {          alias: {"@screens": "./src/screens","@components": "./src/components","@services": "./src/services","@infrastructure": "./src/infrastrcuture","@assets": "./assets",          },        },      ],    ],  };};

I thought this set up would be enough but it was not. Then is tsconfig.json:

{"compilerOptions": {"allowSyntheticDefaultImports": true,"jsx": "react-native","lib": ["dom", "esnext"],"moduleResolution": "node","noEmit": true,"skipLibCheck": true,"resolveJsonModule": true,"strict": true,     // I added this part"baseUrl": ".","paths": {"@assets": ["./assets/*"],"@*": ["src/*"]    }  }}

resolver is working for src directories but the issue is with "assets" directory. I keep changing this line "@assets": ["./assets/*"],

"@assets": ["assets/"],"@assets": ["./assets/"],

I could not figure out how to solve the issue.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>