forked from com-lihaoyi/mill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mill
58 lines (43 loc) · 1.59 KB
/
build.mill
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
package build
import mill._, javascriptlib._
object web extends TypeScriptModule {
// These are all added as devDependencies but I don't think they should be.
def npmDeps: T[Seq[String]] = Task {Seq(
"react@^18",
"react-dom@^18",
"next@^15.0.3"
)}
// TODO: How do I handle devDependencies?
def npmDevDeps: T[Seq[String]] = Task {Seq(
"typescript@^5",
"@types/node@^20",
"@types/react@^18",
"@types/react-dom@^18"
)}
def mainFileName = Task { s"/app/page.js" }
def allFiles = Task.Source(millSourcePath)
def run(args: mill.define.Args) = Task.Command {
os.copy(build0().path, Task.dest / ".next", followLinks = false)
os.call((Task.dest / "node_modules/.bin/next", "start"), stdin = os.Inherit, stdout = os.Inherit)
}
// This is used for making live updates, so needs to look at source folder
def dev(args: mill.define.Args) = Task.Command {
install()
os.remove.all(millSourcePath / "tsconfig.json")
os.call((millSourcePath / "node_modules/.bin/next", "dev", millSourcePath), stdin = os.Inherit, stdout = os.Inherit)
}
def build(args: mill.define.Args) = Task.Command {
build0()
}
def build0 = Task {
os.copy(allFiles().path, Task.dest, mergeFolders = true)
os.copy(install().path / "node_modules", Task.dest / "node_modules", followLinks = false)
os.call((Task.dest / "node_modules/.bin/next", "build"), stdout = os.Inherit)
PathRef(Task.dest / ".next")
}
}
// Documentation for mill.javascriptlib
/** Usage
> mill web.build | grep 'prerendered as static content'
○ (Static) prerendered as static content
*/