I want to avoid using relative pathing when importing other files. For example, I'd like to change something like:
import InputBar from ../../pages/InputBar
to import InputBar from components/pages/InputBar
Normally I would modify the resolve options in webpack, but I'm using create-react-app and don't have access to it.
I would like to avoid using npm run eject
. Is there another way to avoid using relative pathing for imports?
您可以使用rewired ,这将使您可以根据自己的喜好配置react-scripts
,而不必退出CRA。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.