Closed
Description
I propose to add this:
resolve: {
root: path.resolve('src')
...
}
in webpack.config.dev.js
The benefit of this is the following one:
Let say I have the following file structure:
/src
/actions
/components
/views
/App
index.js
styles.css
index.js
index.css
let say I need to call views/App/index.js from src/index.js
With the current webpack.config.dev.js I have to do this:
import App from './views/App';
and this is just a simple use case, I let you imagine if you have to call a component 3 or 4 levels before you should have something like:
../../../components/myComponent
such a pain, such a shame
with
resolve: {
root: path.resolve('src')
...
}
it becomes now so easy and beautiful...
import App from 'views/App';
import BlahBlah from 'components/BlahBlah'; // wherever this is from, it can be so deep in your this no matter
Activity
gaearon commentedon Feb 21, 2017
Thanks for the suggestion! Please search past issues for existing discussions about this.
#253
#388
#636
#651
#741
#1043
#1065
#1136
#1492
tl;dr:
NODE_PATH
environment variable and runningNODE_PATH=src npm start
and other commands.Hope this helps!
modulesDirectories
? #1591OlivierCo commentedon Feb 21, 2017
Sorry I didn't search indeed. Thanks
gaearon commentedon Feb 21, 2017
No worries 😉