generated from tomcl/hlp21-project-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
94 lines (75 loc) · 2.11 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
84
85
86
87
88
89
90
91
92
93
94
#r "paket: groupref FakeBuild //"
#load ".fake/build.fsx/intellisense.fsx"
#if !FAKE
#r "netstandard"
#r "Facades/netstandard" // https://github.com/ionide/ionide-vscode-fsharp/issues/839#issuecomment-396296095
#endif
open System
open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
open Fake.IO.FileSystemOperators
open Fake.JavaScript
let solutionFileName =
!! "*.sln"
|> Seq.toList
|> (function
| [] -> failwithf """build.fsx expects to find a solution file './*.sln' - no file was found. This can be \
created automatically by Visual Studio or Visual Studio Code"""
| [soln] ->
printfn "solution file '%s' found" soln
soln
| files -> failwithf "Build.fsx expects to find a single '*.sln' file but there are two: '%A'" files)
Target.create "Clean" (fun _ ->
!! "src/**/bin"
++ "src/**/obj"
++ "dist"
++ ".fable"
|> Shell.cleanDirs
)
Target.create "CleanFableJS" <| fun _ ->
!! (__SOURCE_DIRECTORY__ @@ "src/**/*.fs.js")
|> Seq.toList
|> File.deleteAll
Target.create "CleanNode" <| fun _ ->
Shell.cleanDir (__SOURCE_DIRECTORY__ @@ "node_modules")
File.delete (__SOURCE_DIRECTORY__ @@ "package-lock.json")
Target.create "DotnetRestore" (fun _ ->
DotNet.restore
(DotNet.Options.withWorkingDirectory __SOURCE_DIRECTORY__)
solutionFileName
)
Target.create "NpmInstall" (fun _ ->
Npm.install id
)
Target.create "Build" (fun _ ->
Npm.run "compile" id
)
Target.create "Dev" (fun _ ->
Npm.run "dev" id
)
Target.create "Dist" (fun _ ->
Npm.run "dist" id
)
Target.create "DistDir" (fun _ ->
Npm.run "dist:dir" id
)
Target.create "KillZombies" <| fun _ ->
Fake.Core.Process.killAllByName <| String.replace ".sln" ".exe" solutionFileName
Fake.Core.Process.killAllByName "node"
Fake.Core.Process.killAllByName "dotnet"
// Build order
"Clean"
==> "DotnetRestore"
==> "NpmInstall"
==> "Build"
"NpmInstall"
==> "Dev"
"NpmInstall"
==> "Dist"
"NpmInstall"
==> "DistDir"
// start build
Target.runOrDefaultWithArguments "Dev"