awesome-typescript-loader icon indicating copy to clipboard operation
awesome-typescript-loader copied to clipboard

Can't get path aliasing to work with webpack

Open darewreck54 opened this issue 5 years ago • 1 comments

I actually posted this on stackoverflow but there is no tag for this project.

https://stackoverflow.com/questions/51624134/aliasing-with-webpack-4-and-awesome-typescript-loader-not-working

I'm basically having issues with getting alias to work properly with webpack 4 and awesome typescript loader. It's not clear to me if its the configuration or what.

Any advice appreciated, Thanks, Derek

darewreck54 avatar Aug 01 '18 01:08 darewreck54

It seems ATL doesn't handle tsconfig paths where the lhs contains an * at the moment.

Not working:

"paths": {
  "*" : ["types/*"],
  "common/*": ["src/stuff/common/"]
}

working fine:

"paths": {
  "common": ["src/stuff/common/"]
}

There's three workarounds I've found:

  1. Rewrite the LHS of the paths so they don't have a * in them - but that isn't always possible.
  2. ... add the mappings with asterisks in them to the webpack config manually. Which sort of defeats the purpose of having a plugin for this in the first place.
  3. Use another plugin to handle path aliasing.
    I've had success with the one ts-loader's github README recommends; tsconfig-paths-webpack-plugin (which b.t.w. "uses work done in awesome-typescript-loader").

sverweij avatar Feb 25 '19 17:02 sverweij