Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Add src/ directory to webpack resolve root config #66

Closed
andersonvom opened this issue Nov 3, 2016 · 0 comments · Fixed by #67
Closed

Add src/ directory to webpack resolve root config #66

andersonvom opened this issue Nov 3, 2016 · 0 comments · Fixed by #67

Comments

@andersonvom
Copy link
Contributor

andersonvom commented Nov 3, 2016

Currently, all imports in the code need to be relative to the current path, making it harder to refactor the code base as it's a pain to have to change all import paths, figuring out how many ../.. are needed.

Adding the src/ directory to webpack's resolve.root config allows developers to go from something like this:

import Header from '../../components/Header';
import TransactionForm from '../TransactionForm';
import * as AppActions from '../../actions';

to something like this:

import Header from 'components/Header';
import TransactionForm from 'containers/TransactionForm';
import * as AppActions from 'actions';

This change is also backwards compatible, so relative imports still work.

andersonvom added a commit to andersonvom/neo that referenced this issue Nov 3, 2016
Adding the `src/` directory to resolve.root allows developers to import
modules without having to give the relative path to the current file
imoprting the module.  This makes it easier to refactor the code as it's
easier to reason about module paths relative to the project's root
folder.

This is also backwards compatible, and relative imports are still
possible.

Closes mozilla#66
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant