Skip to content

Instantly share code, notes, and snippets.

@martinCouso
Last active December 1, 2022 18:38
Show Gist options
  • Save martinCouso/af031611ff430e7ace2f12736d0f554d to your computer and use it in GitHub Desktop.
Save martinCouso/af031611ff430e7ace2f12736d0f554d to your computer and use it in GitHub Desktop.
//tsconfig.json
"compilerOptions": {
...,
// Path alias config
"baseUrl": ".",
"paths": {
"*": [
"src/*",
"*"
]
},
}
yarn add --dev babel-plugin-module-resolver eslint-import-resolver-babel-module eslint-import-resolver-typescript
npm install babel-plugin-module-resolver --save-dev
//babel.config.js
plugins: [
...,
[
'module-resolver',
{
alias: {
assets: './src/assets',
'shared-components': './src/shared-components',
features: './src/features',
'redux-configuration': './src/redux-configuration',
navigation: './src/navigation',
styles: './src/styles',
hooks: './src/hooks',
'global-constants': './src/global-constants',
'global-helpers': './src/global-helpers',
api: './src/api',
app: './src/app',
},
root: './src',
},
],
//.eslintrc.js
settings: {
'import/resolver': {
'babel-module': {},
typescript: {},
},
},
//If you're using WebStorm as your IDE you need to create the webpack.config.js file and add the following code:
//webpack.config.js
const path = require('path');
module.exports = {
resolve: {
alias: {
features: path.resolve(__dirname, './src/features'),
api: path.resolve(__dirname, './src/api'),
app: path.resolve(__dirname, './src/app'),
redux: path.resolve(__dirname, './src/redux-configuration'),
navigation: path.resolve(__dirname, './src/navigation'),
styles: path.resolve(__dirname, './src/styles'),
hooks: path.resolve(__dirname, './src/hooks'),
components: path.resolve(__dirname, './src/shared-components'),
constants: path.resolve(__dirname, './src/global-constants'),
helpers: path.resolve(__dirname, './src/global-helpers'),
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment