How to config babel to import alias like my idea ?
./src
|
--themes.ts // root theme
|
|Module-1
|
--themes/index.ts // child module's theme extend root theme
--component.tsx // import "@themes" instead of "../themes"
|
|Module-2
|
--themes/index.ts // child module's theme extend root theme
--component.tsx // import "@themes" instead of "../themes"
|
|Module-{x} // any modules...
|
--themes/index.ts // child module's theme extend root theme
--component.tsx // import "@themes" instead of "../themes"
At child dirs. module-{x}/.../component.tsx, Inside component.tsx of any module, instead of import "../themes" -> import "@themes"
My regular babel.config.js
plugins: [
[
'module-resolver',
{
root: ['./'],
alias: {
'@themes': './src/themes'
}
}
]
]
is this a right way approach ?
root: ['./src/{module-x}/'],
alias: {
'@themes': './src/{module-x}/themes'
}
import "@themes" access "module-x/themes" of its root module-x