You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[webpack5] styleUrls file names must match component names #9367
Describe the bug
The scss file mechanism is not working as in version 7.0.
To Reproduce
ns create demoApp
Angular > Hello World
cd demoApp
code .
open src/app/item and add a file named item-details.component.scss with the following content:
.test {
background-color: red;
}
change the html file, so that the labels in item-details.component.html has the test class : <Label class="h2 test" ......
change the ts file to reference the scss file: styleUrls: ['item-details.component.scss']
ns run android
the style is correctly applied as expected.
Now rename the scss file to something else (the name must differ from the ts filename). For example xyz.scss and change the ts file to reference it accordingly. styleUrls: ['xyz.scss']
ns run android
There are two warnings during the compilation and the scss is not taken in account anymore.
Expected behavior
This should work as in nativescript 7, our app is looking really weird now because a lot of our styles are not loaded anymore.
Sample project
follow the steps described above
Additional context
I found a workaround: if the last part of the name does not change, it seems to work. So with my example, naming the file xyz.component.scss is working, but xyz.scss is not. This is a breaking change.
This is probably related to #9311 and is a bug in the webpack rules for scss/css files.
The .component.scss files are not affected as they are run through a different set of loaders based on the angular webpack rules.
At the moment for myself I have reverted some of the loader logic to what it was doing in NS7 to make styles work in my app until an official fix is made.
Fixed in #9434 (Angular component CSS handling). Every .css/.scss file other than app.* now goes through the component rule regardless of its name, so styleUrls: ['xyz.scss'] works again.
Activity
Archez commentedon Apr 30, 2021
This is probably related to #9311 and is a bug in the webpack rules for scss/css files.
The
.component.scssfiles are not affected as they are run through a different set of loaders based on the angular webpack rules.At the moment for myself I have reverted some of the loader logic to what it was doing in NS7 to make styles work in my app until an official fix is made.
[-]Breaking change in Nativescript 8[/-][+][webpack5] styleUrls file names must match component names[/+]NathanWalker commentedon Oct 23, 2026
Fixed in #9434 (Angular component CSS handling). Every
.css/.scssfile other thanapp.*now goes through the component rule regardless of its name, sostyleUrls: ['xyz.scss']works again.