DEV Community

Discussion on: Custom import paths and how it can help you

Collapse
 
rkichenama profile image
Richard Kichenama • Edited

Keeping in a stack of TS React, Jest, and Webpack

package.json (for jest)

"moduleMapper": {
  "^src/(.*)": "<rootDir>/src/$1"
}
Enter fullscreen mode Exit fullscreen mode

webpack.config.js

module.exports = {
  "context": path.join(__dirname, '/src'),
  ...
}
Enter fullscreen mode Exit fullscreen mode

allows for import Component from 'src/folder/moduleName';