This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
build.fsx
83 lines (68 loc) · 2.48 KB
/
build.fsx
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#r "paket:
nuget Xake ~> 1.1 prerelease //"
#load ".fake/build.fsx/intellisense.fsx"
// Notice: this is not a traditional FAKE script.
// Instead it uses Xake module to define build targets and rules in CMAKE fashion.
// See https://github.com/FakeBuild/Xake/wiki for more details.
open Xake
open Xake.Tasks
let clientBundle = "src/Client/public/bundle.js"
let serverDllRel = "bin/Debug/netcoreapp2.0/fschathost.dll"
let serverDll = "src/Server/" + serverDllRel
let shellx cmd folder =
let command::arglist | OtherwiseFail(command,arglist) = (cmd: string).Split(' ') |> List.ofArray
shell {
cmd command
args arglist
workdir folder
failonerror
} |> Ignore
do xakeScript {
consolelog Diag
rules [
// main (default) target is to sequentially restore deps and build
"main" <<< [ "restore"; "build" ]
// cleans the build artifacts
"clean" => recipe {
do! rm {file "src/Client/bundle.*"}
do! rm {dir "src/*/bin/*"; verbose }
do! rm {dir "src/*/obj/*"; verbose }
}
// restores packages and node modules
"restore" => recipe {
do! "src/Client" |> shellx "yarn"
do! "src/Server" |> shellx "dotnet restore"
}
// build the client bundle
clientBundle ..> recipe {
// record dependencies so that Xake will track the changes
let! files = getFiles (fileset {
basedir "src/Client"
includes "**/*.fs"
includes "**/*.*css"
includes "webpack.config.js"
includes "yarn.lock"
includes "client.fsproj"
})
do! needFiles files
do! "src/Client" |> shellx "yarn build"
}
serverDll ..> recipe {
do! need [clientBundle]
do! "src/Server" |> shellx "dotnet build"
}
// build the application
"build" <== [serverDll]
// start server and browser in parallel
"start" <== [ "start:server"; "start:browser" ]
// starts the server and runs
"test" <== [ "start:server"; "test-e2e" ]
"start:server" => recipe {
do! need ["build"]
do! "src/Server" |> shellx ("dotnet " + serverDllRel)
}
"test-e2e" => shellx "dotnet run" "test/e2e"
// opens the application in browser, windows only
"start:browser" => shellx "start http://localhost:8083" "."
]
}