react-webpack-generators / react-webpack-template

Simple react webpack template
MIT License
82 stars 44 forks source link

in webpack resolve.alias should be resolve.root #28

Closed wassname closed 8 years ago

wassname commented 8 years ago

Here is a suggestion for an improvement to webpack config. Replace resolve.alias with resolve.root.

Why? Alias is bad because it applied to all imports, and in the current state is adds an extra slash breaks some imports.

E.g. importing 'helpers/actions/ActionWrapper.js' would convert to 'helpers/actions//ActionWrapper.js'

Or am I missing something about the reason it was used?

Instead, add to the search path using resolve.root.

PR submitted.

weblogixx commented 8 years ago

Hi @wassname,

I will certainly have a look at it and give it a try. The problem with the double slashes was known, I just did not know the cause of it. Thanks for your support!

weblogixx commented 8 years ago

Hi @wassname,

the Idea itself is nice, but I run into errors when trying it out. Seems like we would have to change the way requires are inserted for css and other files. I will try to include this in the next major version of the package (2.0.0), which will include some breaking changes (unit testing via enzyme and other stuff).