-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathui-build.sbt
More file actions
49 lines (37 loc) · 1.61 KB
/
ui-build.sbt
File metadata and controls
49 lines (37 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import scala.sys.process.Process
/*
* UI Build hook Scripts
*/
// Execution status success.
val Success = 0
// Execution status failure.
val Error = 1
// True if build running operating system is windows.
val isWindows = System.getProperty("os.name").toLowerCase().contains("win")
// Execute on commandline, depending on the operating system. Used to execute npm commands.
def runOnCommandline(script: String)(implicit dir: File): Int = {
if(isWindows){ Process("cmd /c " + script, dir) } else { Process(script, dir) } }!
// Execute `npm install` command to install all node module dependencies. Return Success if already installed.
def runNpmInstall(implicit dir: File): Int =
runOnCommandline(FrontendCommands.dependencyInstall)
// Execute frontend prod build task. Update to change the frontend prod build task.
def executeProdBuild(implicit dir: File): Int = {
if (runNpmInstall == Success) {
runOnCommandline(FrontendCommands.buildProd)
} else {
Error
}
}
// Create frontend build tasks for prod execution.
lazy val `ui-prod-build` = taskKey[Unit]("Run UI build when packaging the application.")
`ui-prod-build` := {
val skipFrontend = sys.props.get("skipFrontend").getOrElse("false").toBoolean
if (!skipFrontend) {
implicit val userInterfaceRoot: File = baseDirectory.value / "ui"
if (executeProdBuild != Success) throw new Exception("Oops! UI Build crashed.")
}
}
// Execute frontend prod build task prior to play dist execution.
dist := (dist dependsOn `ui-prod-build`).value
// Execute frontend prod build task prior to play stage execution.
stage := (stage dependsOn `ui-prod-build`).value