How to use module name alias in angular cli?

Using a stand-alone web package, you can use anti-aliasing to solve the module. 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 as alias resolution inside angular cli?

+5
source share
1 answer

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

The values โ€‹โ€‹of the path array are relative to baseUrl . Here is a usage example:

 "compilerOptions": { "baseUrl": ".", "paths": { "@app/*": ["app/*"] } } 
+1
source

Source: https://habr.com/ru/post/1257516/


All Articles