0

I'm working on a webpage developed with AngularJS and SASS, and depending on the browser url needs to change the stylesheet file.

Simplifying, I have two URL pointing to the same instance of the web, and depending on the URL, I need to load different stylesheet

  • url_a.com -> stylesA.css
  • url_b.com -> stylesB.css

In order to detect the url, i'm using Angulars $location service.

Local development works fine, but the deployed app, does not change styles.

Index.html:

 <link rel="stylesheet" ng-href="styles/{{mainStylesSheet}}">

AppController

$rootScope.mainStylesSheet = ($location.host == 'urlA') ? main-a.css : main-b.css;

Appreciate your help. Thanks

marc
  • 527
  • 6
  • 23
  • can't you just deploy separate copies of the app? – Daniel A. White Sep 01 '17 at 13:51
  • You want to achieve something like on https://stackoverflow.com/questions/15193492/how-to-include-view-partial-specific-styling-in-angularjs ? – ice 13 Sep 01 '17 at 13:54
  • @DanielA.White one of the requirements is not to use two instances of the app... :( – marc Sep 01 '17 at 13:57
  • @ice13 actually... what I need to load is the entire main.css, which contains different _@imports_, not partial styles depending on the url "path". – marc Sep 01 '17 at 14:08
  • could you rewrite it on your webserver? – Daniel A. White Sep 01 '17 at 15:23
  • @DanielA.White what do you mean? – marc Sep 01 '17 at 15:29
  • some web servers can rewrite the response based on certain conditions – Daniel A. White Sep 01 '17 at 15:29
  • Is the problem that production doesn't work or stylesheet changing is not working? can you post a screenshot of what link looks like in production? – Shyam Babu Sep 01 '17 at 15:56
  • @ShyamBabu the problem is that in production, the app only loads bootstrap css, not my custom stylesheets. And of course, no css change between URLs. – marc Sep 04 '17 at 07:36
  • In production index.html check if link tag is appearing with correct URL. If it is not appearing in production only,then there is high chance that some minification might be affecting the url. – Shyam Babu Sep 04 '17 at 09:33

0 Answers0