Help me with babel.js absolute pathes or in general with react native absolute pathes.

Job ID: 31447199

Budget: €8 – €30 EUR

Please write "jsbabel" in front of your proposal, so I know you read the text.

I'm developing software consisting out of a react web app and a react native mobile app.

For both, I want to use the same kind of absolute paths.

An example of my folder structure:

- node_modules
- src
--- app.jsx
--- dashboard
------- dashboard.jsx
------- settings-page.jsx

In the web app, i use:

resolve: {
extensions: [".js", ".json", ".jsx"],
modules: [path.resolve(__dirname, "./src"), "node_modules"],
},

to make the following possible from the dashboard.jsx file:

import React from "react" <-- Gets imported from node_modules
import SettingsPage from "dashboard/settings-page" <-- Gets imported from src/dashboard/settings-page
import App from "app"

Now I want to have the same style of absolute paths for my mobile app. So that src is kind of the root. I tried some tips from the internet. But they always wanted me to make an alias like @src or so. But I just want it to work like in the web app without any prefixes. Just start the path from the src folder, when that makes sense.

I'm using react native with expo.

My question is, how can I achieve this?

Greetings, Julius
Related categories: JavaScript Web Development React Native