A Babel plugin to add a new resolver for your modules when compiling your code using Babel. This plugin allows you to add new "root" directories that contain your modules. It also allows you to setup a custom alias for directories, specific files, or even other npm modules.
Description
This plugin can simplify the require/import paths in your project. For example, instead of using complex relative paths like ../../../../utils/my-utils, you can write utils/my-utils. It will allow you to work faster since you won't need to calculate how many levels of directory you have to go up before accessing the file.
// Use this:import MyUtilFn from 'utils/MyUtilFn';// Instead of that:import MyUtilFn from '../../../../utils/MyUtilFn';// And it also work with require calls// Use this:const MyUtilFn = require('utils/MyUtilFn');// Instead of that:const MyUtilFn = require('../../../../utils/MyUtilFn');
IntelliJ/WebStorm: You can mark your module directories as "resources root" e.g if you have ../../../utils/MyUtilFn you can mark
../../../utils as "resources root". This has the problem that your alias also has to be named utils. The second option is to add
a webpack.config.js to your project and use it under File->Settings->Languages&Frameworks->JavaScript->Webpack. This will trick webstorm
into resolving the paths and you can use any alias you want e.g.: