angular-cli:CSS 依赖于环境 [英] angular-cli: CSS dependent on environment
问题描述
我正在使用带有 angular-cli
的 Angular 2.对于客户 A,CSS 文件 style.A.css
是相关的,对于客户 B,它是 style.B.css
.是否可以使 apps[0].styles
中定义的 css 文件依赖于活动环境?如果没有,有什么优雅的解决方案吗?
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?
CSS 的范围是整个应用程序,就像一个完全不同的外观.所以组件范围是不够的.
The CSS's scope is the whole app, like a totally different appearance. So component scope will not be sufficient.
推荐答案
我们使用了不同的应用名称来解决这个问题.我们在 angular-cli.json 中定义了不同的客户,并在那里定义了哪个 style.css 用于哪个应用程序名称.我们有一个默认值,然后是我们拥有的所有客户,对于每个客户,我们可以说我们想要使用哪些资产、哪些风格甚至哪种环境就足够了.
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.
要启动和构建应用程序,您只需调用ng serve app-name"或ng serve"作为默认值
And to start and build the application you then only have to call 'ng serve app-name' or 'ng serve' for default
这篇关于angular-cli:CSS 依赖于环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!