-
Notifications
You must be signed in to change notification settings - Fork 12k
Does Angular Cli 6 support @import ~ anymore? #11435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Rename the file from "/src/styles/_variables.scss" to "/src/styles/variables.scss" "import" is part of typescript and angular 6 implements typescript |
That's interesting. While stackblitz appears to work, running ng serve locally still produces the same error after change the file name:
Here is my repo: https://github.com/dereklin/myng6app On another note, stackblitz seems to cache my old app. When I do https://stackblitz.com/github/dereklin/myng6app, I can still see _variables.scss instead of the newly named variable.scss. But I really think _variables.scss is the right file name since they are partials and I don't want sass to compile them: https://kolosek.com/sass-import/ |
But that's relative import. My original question is regarding the support of @import ~. It used to work before my upgrading to Angular 6. Some claim it's still working (storybookjs/storybook#3814). I want to find out if it's indeed supported still. |
Did you find the way how to solve the issue? |
The usage of the tilde was/is not officially supported and is actual an artifact of the internal implementation of the build system. While it may currently work in certain situations, it is not guaranteed to continue to function in the future. In the style use cases outlined above, a relative path or the use of the |
@clydin Is this a change of stance? On #9166 and #9184 (back in January), you noted that this syntax being unsupported was a defect. It also appears that there are unit tests in 6.0.x that check if tilde imports work. Has something changed in policy? EDIT: For what it's worth, I'm seeing the same behavior in a fresh v6 project using LESS, so the symptom isn't unique to SCSS. |
The Angular Material documentation contained a usage of the tilde and to prevent wide spread breakage a set of tests for a limited usage of the tilde were added at that time. These tests were carried over into 6.x to attempt to ease transition. However, there is currently not a guarantee that the tilde will continue to function (even in the tested limited capacity) moving into the future. |
@clydin I see. Given that this functionality happens to work sometimes (despite not being intentionally supported), what sort of work do you think it would take to make it intentionally supported? I'd be interested in taking a stab at it if it's not too hairy. It's quite a handy thing to have, after all. |
@NickLanam I've proposed an idea that may solve this issue in #12573. Let me know if that would handle your use-case, especially if @clydin is unwilling to commit to supporting |
@damienwebdev That proposal would add a fair bit of flexibility, but I'm not sure that it achieves the same use case. In the issue here, a working implementation avoids the need for manually specifying where to find each thing. It defaults to finding |
In my case (Angular 7): angular.json
styles.scss |
What about server side applications? In my
to the Do I have to add it also in |
In my case "assets": [
"src/assets"
]
When I try to do so I get an error:
"@angular-devkit/build-angular": "^0.13.9" |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I just create a brand new app with angular cli 6. I tried use do
But I got file not found error.
Here is my code:
https://stackblitz.com/github/dereklin/myng6app?file=src%2Fapp%2Fapp.component.scss
Is @import ~ no longer supported?
The text was updated successfully, but these errors were encountered: