Support tilde path alias to node_modules in angular.json
Seems strange that I can do this in a .scss file
@import "~font-awesome/css/font-awesome.css";
But not in angular.json
styles": [
"~/ionicons/scss/ionicons.scss",
The full path must be added
./node_modules/ionicons/scss/ionicons.scss
It should also work for scripts.
The tilde usage is an artifact of certain internal implementation aspects of the system and is not officially supported. As a result, it is not recommended to rely on its usage as it may or may not function as expected in the future.
@clydin well explained !
@clydin but its a great shortcut. Why not promote this to a feature request?
Because as a path the tilde already has a meaning. It represents the user's home directory. Reusing a symbol with an existing meaning in the same context is confusing and error-prone. Especially considering there are already a multitude of methods to adjust the behavior of non-relative path resolution.
It is also not standardized within webpack itself. Only certain webpack loaders support it and the behavior is dependent upon the implementation within the actual loader (webpack proper has no knowledge of the tilde's special meaning).
Its use also presumes that webpack and a webpack loader that supports its use are used to process the resource in question. Which may or may not be the case now or in the future.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.