5

Using standalone webpack, you could use aliasing for module resolving. something like this inside your webpack.config file, config.resolve block:

config.resolve = {
    extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'],
    alias: {
      'app': 'src/app',
      'common': 'src/common',
       'a_module_name': 'file_path_to_module_name'
    }
  };

How do you use webpack like alias resolution inside angular cli?

3
  • I'm trying to solve the same issue, do you have any solution for this? Commented Nov 24, 2016 at 13:42
  • currently not. Perhaps, you can upvote the question so it receives more attention. I actually moved away from cli, because of this and started using angular 2 webpack starter Commented Nov 24, 2016 at 14:32
  • I'm facing the same issue, and according to a discussion at github it looks like they are not going to exposed the webpack config, but I can't find any work around for this Commented Nov 24, 2016 at 14:36

1 Answer 1

1

Try using the typescript compilerOptions paths array inside your tsconfig.json file:

The paths array values are relative to the baseUrl. Here is an example usage:

"compilerOptions": {
  "baseUrl": ".",
  "paths": {
    "@app/*": ["app/*"]
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.