I'm still confused how to resolve module paths with webpack. Now I write:
myfile = require('../../mydir/myfile.js')
but I'd like to write
myfile = require('mydir/myfile.js')
I was thinking that resolve.alias may help since I see a similar example using { xyz: "/some/dir" } as alias then I can require("xyz/file.js").
But if I set my alias to { mydir: '/absolute/path/mydir' }, require('mydir/myfile.js') won't work.
I feel dumb because I've read the doc many times and I feel I'm missing something.
What is the right way to avoid writing all the relative requires with ../../ etc?
resolve.aliasworks exactly the way you suggested. I wonder if it was failing because of something else in yourresolveconfiguration. I usealias{ mydir: path.resolve( __dirname, 'path', 'to', 'mydir' )andrequire( 'mydir/myfile.js' )works just fine. - sethro