Preact-cli: alias to the src folder

Created on 16 Jun 2017  路  7Comments  路  Source: preactjs/preact-cli

That is a suggestion.

What about adding an alias to the webpack config that will point to the src folder to avoid the ../.. relative paths. Something like:

      alias: {
        app: path.resolve(__dirname, '../src/'),
     }

So instead of having

import Profile from '../routes/profile';

Will have

import Profile from 'app/routes/profile';

If you think is a good idea, I can submit a small PR for it.

All 7 comments

I'd love to have this, as long as we call it src so it's 1:1.

      alias: {
        src: path.resolve(__dirname, '../src/'),
     }

It's particularly useful in tests.

@developit Cool! I make a PR if thats fine for you.

Yup!

Cool! will send my PR during this week(end).

I made one of those PRs a while ago and we decided to keep that up to the user after the config PR lands. I do agree with us waiting on these to make the app less opinionated.

Custom config has landed. Feel free to add your aliases there :)

Thx, I will close the issue :)

Was this page helpful?
0 / 5 - 0 ratings