A codemod that swaps relative imports for aliases — your go-to buddy for project refactoring!
npm install -g aliasify-imports
Run the transformation on your source directory:
aliasify-imports --srcDir src --alias @
-
--alias
(Default:@
) - The alias to use for the import paths. -
--srcDir
(Default:src
) - The source directory to use for the alias. -
--parser
(Default: 'tsx') - The parser to use -
--extensions
(Default: 'js,jsx,ts,tsx') - The file extensions to transform -
--help
- Display the help message
// In src/components/Header/index.js
import Logo from '../../assets/images/logo.png';
import Utils from '../../../utils/helpers';
import Footer from '../Footer';
// In src/components/Header/index.js
import Logo from '@/assets/images/logo.png';
import Utils from '@/utils/helpers';
import Footer from '@/components/Footer';