Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular-cli: CSS dependent on environment

I am using Angular 2 with angular-cli. For customer A the CSS file style.A.css is relevant, for customer B it's style.B.css. Is it possible make the css files defined in apps[0].styles dependent on the active environment? If not, any elegant solution for this?

The CSS's scope is the whole app, like a totally different appearance. So component scope will not be sufficient.

like image 431
d135-1r43 Avatar asked Nov 23 '16 09:11

d135-1r43


People also ask

Can I use CSS in Angular?

Angular applications are styled with standard CSS. That means you can apply everything you know about CSS stylesheets, selectors, rules, and media queries directly to Angular applications. Additionally, Angular can bundle component styles with components, enabling a more modular design than regular stylesheets.

What is environment TS in Angular?

A project's src/environments/ folder contains the base configuration file, environment.ts , which provides a default environment. You can add override defaults for additional environments, such as production and staging, in target-specific configuration files.

What is used Angular-CLI json?

angular-cli. json is used to configure the angular 2 projects.

Where is Angular-CLI json located?

Where is Angular json CLI file? The angular-cli. json should be located in the root folder of the project.


1 Answers

We used different app-names to solve that problem. We defined different customers in our angular-cli.json and defined there which style.css to use for which app name. There we have a default and then all the customers we have and for each we can say which assets we want to use and which styles and even which enviornment is sufficient.

And to start and build the application you then only have to call 'ng serve app-name' or 'ng serve' for default

like image 64
Erbsenkoenig Avatar answered Oct 19 '22 23:10

Erbsenkoenig