Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use resolve.root instead of resolve.alias for project folders #49

Closed
jedwards1211 opened this issue Sep 17, 2015 · 6 comments
Closed

use resolve.root instead of resolve.alias for project folders #49

jedwards1211 opened this issue Sep 17, 2015 · 6 comments

Comments

@jedwards1211
Copy link
Owner

(@grigio @AdamBrodzinski you guys will probably find this useful)
I can't believe it, but I only now discovered Webpack's resolve.root config option. By setting it to the parent directory of app, the aliases we made like to app and other folders are unnecessary, and moreover they're a bit dangerous: when I aliased a util folder in my own project, some Node.js SHA-1 code that tries to require a util/... somewhere failed to resolve it. Using resolve.root instead fixed everything.

I think alias was really only intended to override module locations, rather than how we're using it in this project right now

@AdamBrodzinski
Copy link
Collaborator

Ah lol thanks for the heads up!!

@jedwards1211
Copy link
Owner Author

Ah, so with, root: path.join(__dirname, '..') I get the following compile error:

ERROR in ../debug
Module parse failed: /home/andy/meteor-webpack-react/debug Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| #!/bin/bash
| 
| ./core-js-custom-build
 @ ../~/webpack-dev-server/~/socket.io-client/lib/index.js 9:12-28

I think it would make the most sense to rename the app folder to src and make it the webpack root.
@AdamBrodzinski what do you think?

@jthomaschewski
Copy link
Contributor

I've been using root: path.join(__dirname, '../app') for a while now and didn't experienced any problems.

Imports are relative to the app directory import App from 'components/App'; - So your idea of renaming to src should work fine as I'm using app already like that without any issues.

btw: Webstorm IDE is only able to find imports if I do them relative to the app directory - at least in default configuration when opening "meteor-webpack-react" folder as project. I have no idea why but for me the root => ../app or ../src solution is the best so far.

@AdamBrodzinski
Copy link
Collaborator

root: path.join(__dirname, '..') works for me too, thanks again! I think we should prob. include this unless you think it will error on some cases.

@jedwards1211
Copy link
Owner Author

@AdamBrodzinski you didn't have that same issue with root: path.join(__dirname, '..')? Weird...in any case I think having the app folder as root makes the most sense, because we're encouraging users to put all of their own code there anyway.

@AdamBrodzinski
Copy link
Collaborator

oh yea speaking of renaming to src is ok with me too (i think that was another issue), either way works for me.

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

No branches or pull requests

3 participants