Nativescript-angular: Using multiple styleUrls does not work

Created on 17 Mar 2016  路  9Comments  路  Source: NativeScript/nativescript-angular

If I pass multiple .css files into a @Component decorator鈥檚 styleUrls property, only rules in the last .css file are applied. For instance in the code below only the rules in two.css are applied:

@Component({
  selector: "foo",
  template: "...",
  styleUrls: ["path/to/one.css", "path/to/two.css"]
})

This is a reasonably big limitation because using @import in .css files imported by Angular also doesn鈥檛 appear to work (which might be another issue?).

Thanks.

Most helpful comment

Well fixing that one was a bit harder than I expected since it required a fix to tns-core-modules, but we're finally there. I just pushed an upgrade to [email protected] and [email protected] to the Groceries app that fixes the problem.

phew

All 9 comments

It seems to work fine on my end.

The renderer doesn't contain any code that resolves CSS files -- the magic is done by Angular. Could you check if the path to the CSS file that doesn't get loaded is correct?

Ok this is super weird. This seems to work when the CSS files target the same component, but as soon as they target different components the styles no longer seem to be applied. I uploaded an example https://github.com/tjvantoll/angular-css-issue

It turned out there were two bugs lurking in that codebase. I fixed those, and your app runs fine on my end. Please upgrade to [email protected].

Thanks for the fast turnaround @hdeshev.

I tried this out and it appears to work, although I鈥檝e hit a possibly related bug now鈥攔ules that I apply in stylesheets in the stylesUrls of pages that aren鈥檛 the first page in my app aren鈥檛 applied.

It鈥檚 probably easiest to just see this in Groceries. These styles are applied exactly as I鈥檇 expect, and these aren鈥檛. I can try to limit this down tomorrow, but it鈥檚 getting near the end of the day here and just wanted to make sure you were aware.

I鈥檒l reopen this issue for now. If you鈥檇 prefer for this to be in a separate issue let me know.

Well fixing that one was a bit harder than I expected since it required a fix to tns-core-modules, but we're finally there. I just pushed an upgrade to [email protected] and [email protected] to the Groceries app that fixes the problem.

phew

I used every available positive emoji to express my gratitude. The fix works great 馃榾

I'm kinda lost halfway tho

I'm having the same issue with the app not applying both stylesheets,
How do I apply the fix that was updated?

Was this page helpful?
0 / 5 - 0 ratings