tj / frontend-boilerplate

webpack-react-redux-babel-autoprefixer-hmr-postcss-css-modules-rucksack-boilerplate (unmaintained, I don't use it anymore)
2.93k stars 268 forks source link

Added aliases to webpack #38

Closed r3nya closed 8 years ago

r3nya commented 8 years ago

Hey! We can use aliases from webpack to resolve paths.

pgilad commented 8 years ago

Isn't it safer to be more explicit with aliases: instead of actions use ^actions\/

r3nya commented 8 years ago

@pgilad good catch! :+1:

tj commented 8 years ago

neat! Do you know if there's a way we can just do imports relative to root without aliases? ex /components/foo, that would be a tiny bit more elegant I think if possible, instead of having an alias per dir

aziz commented 8 years ago

@tj this is how you can do it

  resolve: {
    extensions: ['', '.js', '.jsx'],
    root: [
       path.resolve(__dirname, 'client'), 
       path.resolve(__dirname, 'node_modules')
    ],
  },

and the you do imports like this:

import Header from 'components/Header'
tj commented 8 years ago

cool having the ones that don't need to be maintained sounds good to me!

tj commented 8 years ago

Still like this but we'll have redo it with the above changes