0

I am trying to use different color theme in my 3 environments: dev (green), uat(blue) and prod(red).

I would like to know if, I can read the environment variable in scala in global.scala

override def onStart(app: Application) {
  val env = System.getenv("SYSTEM_ENV")    //{DEV|UAT|PRD}
} 

And then do something on the LESS file that I have, myTheme.LESS

@basecolor: #3B6A52;

which will be read from my other CSS/LESS file as the base background base color

Can I have some logic here to determine the color from my scala variable? e.g. if dev then green else if ....etc

Or if I can have 3 mytheme files, e.g. mythemeRed.LESS, mytmemeBlue.LESS could be determined by play to read only one of them.

Please shed me some light and any idea is welcome.

4

1 回答 1

0

我认为不可能以这种方式混合 javascript 和 LESS。我只会做类似的事情:

if (env === "DEV"){
    var styleRef = document.createElement("link");
    styleRef.setAttribute("rel", "stylesheet");
    styleRef.setAttribute("type", "text/css");
    styleRef.setAttribute("href", "dev-style.css");
    document.getElementsByTagName("head")[0].appendChild(styleRef);
}
else if (env === "UAT"){
...
}

等等。然后,您可以根据您的环境获取正确的编译 CSS 文件。

于 2013-08-02T15:44:58.163 回答