Skip to content

Instantly share code, notes, and snippets.

@abha57
Last active January 26, 2021 13:26
Show Gist options
  • Select an option

  • Save abha57/5f3e876aab25dcf8cfdf59f019732314 to your computer and use it in GitHub Desktop.

Select an option

Save abha57/5f3e876aab25dcf8cfdf59f019732314 to your computer and use it in GitHub Desktop.
absolute paths resolve
//jsconfig ==> to make editor recognize absolute path.
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["/*"],
"@src/*": ["src/*"],
"@any-other-folder/*": ["src/client/../any-other-folder/*"] ==> absolute path to any other folder
}
},
"exclude": ["node_modules"]
}
// babelrc ==> to compile absolute paths
"plugins": [
[
"babel-plugin-root-import",
{
"paths": [
{
"rootPathPrefix": "~",
"rootPathSuffix": "./"
},
{
"rootPathPrefix": "@src",
"rootPathSuffix": "src"
},
{
"rootPathPrefix": "@any-other-folder",
"rootPathSuffix": "src/client/../any-other-folder"
}
]
}
]
]
if eslint is breaking up, try editing 'settings' of eslintrc:
"settings": {
"import/resolver": {
"babel-plugin-root-import": [
{
"rootPathPrefix": "@src",
"rootPathSuffix": "src"
},
{
"rootPathPrefix": "@any-other-folder",
"rootPathSuffix": "src/client/../any-other-folder"
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment