Skip to content
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.

Is it possible to set up an absolute path for import in css and js? #60

Closed
opportunato opened this issue Jun 15, 2015 · 6 comments
Closed

Comments

@opportunato
Copy link

Hey, another question.

The solution when you have to set paths relative to the position of the file you are importing to, looks rather inconvenient, because when you move one file, you have to update not only the import paths of modules that use it, but also the paths of modules it imports itself. It bring an unnecessary level of complexion.

Is it possible to somehow change it, so it looks for the files always starting from the /src folder and down?

@gpbl
Copy link
Owner

gpbl commented Jun 15, 2015

Nope you can just use relative paths. Try to keep only one nest level in your directories: this should prevent the most of the hassle during refactoring....

@opportunato
Copy link
Author

@gpbl For a project with a lot of components using a flat directory structure is really not the best solution. Are you sure that webpack doesn't support it the other way?

@gpbl
Copy link
Owner

gpbl commented Jun 15, 2015

In my experience nested directories for components don't help at all... try to split your components using the atomic design principles: you will end with three/four directories and much less pain :)

@opportunato
Copy link
Author

So, you are talking about splitting components folder into several ones? Don't you think that having several directories in the component one looks more logical?

I wan't thinking about three and more levels of nesting, btw. %)

@gpbl
Copy link
Owner

gpbl commented Jun 15, 2015

It looks more logical but in practice I've found they are harder to organize. You will find yourself refactoring quite often.

Atomic design principles IMHO fit great in a react application. You can split your components into atoms, molecules, organisms and pages directories and you won't need thiking too much about naming and nesting.

@opportunato
Copy link
Author

Ok, thanks!

I'll try it this way.

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

No branches or pull requests

2 participants