Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use module name aliasing in angular cli?

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?

like image 549
hannes neukermans Avatar asked Nov 08 '22 08:11

hannes neukermans


1 Answers

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/*"]
  }
}
like image 195
kampsj Avatar answered Jan 04 '23 01:01

kampsj