babel-plugin-tsconfig-paths-alias
v1.0.3
Published
Resolve imports/requires based on paths from tsconfig.json
Downloads
3
Readme
Babel plugin for resolving path aliases from tsconfig.json
Fork from babel-plugin-tsconfig-paths
but fix the correct file extensions
Install
npm install -D babel-plugin-tsconfig-paths
Configure
// .babelrc
{
"plugins": [
[
"babel-plugin-tsconfig-paths",
{
"relative": true,
"extensions": [
".js",
".jsx",
".ts",
".tsx",
".es",
".es6",
".mjs"
],
"rootDir": ".",
"tsconfig": "tsconfig.json",
"transformFunctions": [
"require",
"require.resolve",
"System.import",
"jest.genMockFromModule",
"jest.mock",
"jest.unmock",
"jest.doMock",
"jest.dontMock",
"jest.setMock",
"require.requireActual",
"require.requireMock"
]
}
]
]
}
relative
: Generate relative paths instead of absolute paths when converting aliased import paths.- Default:
true
- Default:
extensions
: Which file extensions to resolve.- Default:
[".js", ".jsx", ".ts", ".tsx", ".es", ".es6", ".mjs"]
- Default:
rootDir
: Where to look fortsconfig.json
.- Default:
process.cwd()
- Default:
tsconfig
: Relative/absolute location oftsconfig.json
- Default:
./tsconfig.json
- Default:
transformFunctions
: Which functions to transform aliases inDefault:
[ "require", "require.resolve", "System.import", "jest.genMockFromModule", "jest.mock", "jest.unmock", "jest.doMock", "jest.dontMock", "jest.setMock", "require.requireActual", "require.requireMock" ]