Create-react-app: Webpack Resolve

Created on 9 Apr 2017  路  4Comments  路  Source: facebook/create-react-app

Can we have webpack resolve for CRA? So it will help us a lot and provide better experience when developing.

Instead of import x from '../../where/my/module/is'; we can use import x from 'where/my/module/is';.

I suggest we include src as module resolved by default.

Most helpful comment

Sorry my bad, it already solved by adding NODE_PATH=src on .env.

All 4 comments

Sorry my bad, it already solved by adding NODE_PATH=src on .env.

@hellowin it does not work for me "react-scripts": "1.0.13",
I tried more cases src src/* ./src ./src/*
I ejected app looked into code, and it should add them, but nope :cry:
It seems .env ignores NODE_PATH, or how it works.


It's works only when added in front of npm script

"start": "NODE_PATH=$NODE_PATH:src react-scripts start",

That means it's probably already set on your system / environment. .env does not override already set variables.

@Timer yes, when I log NODE_PATH I get some system node paths

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jnachtigall picture jnachtigall  路  3Comments

Evan-GK picture Evan-GK  路  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments

alleroux picture alleroux  路  3Comments

AlexeyRyashencev picture AlexeyRyashencev  路  3Comments