angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Support tilde path alias to node_modules in angular.json

Open atodd-geoplan opened this issue 8 years ago • 5 comments

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.

atodd-geoplan avatar Jun 15 '18 09:06 atodd-geoplan

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 avatar Jun 18 '18 13:06 clydin

@clydin well explained !

zsuswy avatar Aug 26 '18 03:08 zsuswy

@clydin but its a great shortcut. Why not promote this to a feature request?

atodd-geoplan avatar Aug 27 '18 21:08 atodd-geoplan

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.

clydin avatar Aug 27 '18 21:08 clydin

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.