generated from fission-codes/project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJustfile
218 lines (157 loc) Β· 5.08 KB
/
Justfile
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Variables
# =========
config := "production"
dist := "build"
node_bin := "./node_modules/.bin"
workbox_config := "./src/Javascript/workbox.config.cjs"
# Tasks
# =====
@default: dev-build
just config={{config}} dev-server & just config={{config}} watch
@hot:
just config={{config}} dev-build
just config={{config}} hot-server & \
just config={{config}} watch-css & \
just config={{config}} watch-html & \
just config={{config}} watch-typescript-dev
@hot-recovery:
just config={{config}} dev-build
just config={{config}} hot-server-recovery & \
just config={{config}} watch-css & \
just config={{config}} watch-html & \
just config={{config}} watch-typescript-dev
# Parts
# =====
@css:
echo "π Compiling CSS"
npx node src/Javascript/generate-css-modules.js
@elm-dev:
echo "π³ Compiling Elm"
elm make \
--output {{dist}}/application.js \
src/Application/Main.elm
elm make \
--output {{dist}}/recover/application.js \
src/Application/Recovery/Main.elm
@elm-production:
echo "π³ Compiling Elm (optimised)"
elm make \
src/Application/Main.elm \
--output {{dist}}/application.js \
--optimize
elm make \
--output {{dist}}/recover/application.js \
--optimize \
src/Application/Recovery/Main.elm
@favicons:
echo "π Copying favicons"
cp -RT src/Favicons/ {{dist}}
@fonts:
echo "π€ Copying fonts"
mkdir -p {{dist}}/fonts/
cp node_modules/fission-kit/fonts/**/*.woff2 {{dist}}/fonts/
@html:
echo "π Copying HTML"
cp src/Html/Main.html {{dist}}/index.html
mkdir -p {{dist}}/recover
cp src/Html/Recovery/Main.html {{dist}}/recover/index.html
@images:
echo "π Copying images"
cp -RT node_modules/fission-kit/images/ {{dist}}/images/
cp -RT src/Images/ {{dist}}/images/
@typescript-dev:
echo "βοΈ Bundling typescript"
{{node_bin}}/esbuild \
--define:CONFIG_ENVIRONMENT="\"{{config}}\"" \
--define:CONFIG_API_ENDPOINT="$(jq .API_ENDPOINT config/{{config}}.json)" \
--define:CONFIG_LOBBY="$(jq .LOBBY config/{{config}}.json)" \
--define:CONFIG_USER="$(jq .USER config/{{config}}.json)" \
--bundle \
--sourcemap \
--outfile={{dist}}/bundle.min.js \
src/Javascript/index.ts
{{node_bin}}/esbuild \
--define:CONFIG_ENVIRONMENT="\"{{config}}\"" \
--define:CONFIG_API_ENDPOINT="$(jq .API_ENDPOINT config/{{config}}.json)" \
--define:CONFIG_LOBBY="$(jq .LOBBY config/{{config}}.json)" \
--define:CONFIG_USER="$(jq .USER config/{{config}}.json)" \
--bundle \
--sourcemap \
--outfile={{dist}}/recover/bundle.min.js \
src/Javascript/recovery.ts
@typescript-prod:
echo "βοΈ Bundling minified typescript"
{{node_bin}}/esbuild \
--define:CONFIG_ENVIRONMENT="\"{{config}}\"" \
--define:CONFIG_API_ENDPOINT="$(jq .API_ENDPOINT config/{{config}}.json)" \
--define:CONFIG_LOBBY="$(jq .LOBBY config/{{config}}.json)" \
--define:CONFIG_USER="$(jq .USER config/{{config}}.json)" \
--bundle \
--minify \
--sourcemap \
--outfile={{dist}}/bundle.min.js \
src/Javascript/index.ts
{{node_bin}}/esbuild \
--define:CONFIG_ENVIRONMENT="\"{{config}}\"" \
--define:CONFIG_API_ENDPOINT="$(jq .API_ENDPOINT config/{{config}}.json)" \
--define:CONFIG_LOBBY="$(jq .LOBBY config/{{config}}.json)" \
--define:CONFIG_USER="$(jq .USER config/{{config}}.json)" \
--bundle \
--minify \
--sourcemap \
--outfile={{dist}}/recover/bundle.min.js \
src/Javascript/recovery.ts
@manifests:
echo "π
°οΈ Copying manifest files"
cp -RT src/Manifests/ {{dist}}
# Development
# ===========
@clean:
rm -rf {{dist}} || true
mkdir -p {{dist}}
@dev-build: clean html css typescript-dev elm-dev fonts favicons manifests images
@build: clean html css elm-production typescript-prod fonts favicons manifests images production-service-worker
@production-service-worker:
echo "βοΈ Generating service worker"
NODE_ENV=production npx workbox generateSW {{workbox_config}}
@dev-server:
echo "π§ Putting up a server for ya"
echo "http://localhost:8004"
miniserve --spa --index index.html --port 8004 build
@hot-server:
echo "π₯ Start a hot-reloading elm-live server at http://localhost:8004"
{{node_bin}}/elm-live src/Application/Main.elm \
--hot \
--host 0.0.0.0 \
--port=8004 \
--pushstate \
--dir={{dist}} \
-- \
--output={{dist}}/application.js \
--debug
@hot-server-recovery:
echo "π₯ Start a hot-reloading (only for the recovery app!) elm-live server at http://localhost:8004"
{{node_bin}}/elm-live src/Application/Recovery/Main.elm \
--hot \
--host 0.0.0.0 \
--port=8004 \
--dir={{dist}} \
-- \
--output={{dist}}/recover/application.js \
--debug
@install-deps:
npm install
@watch:
echo "π Watching for changes"
just config={{config}} watch-css & \
just config={{config}} watch-elm & \
just config={{config}} watch-html & \
just config={{config}} watch-typescript-dev
@watch-css:
watchexec -p -w src -f "*/Css/**/*.*" -i build -- just config={{config}} css
@watch-elm:
watchexec -p -w src -e elm -- just config={{config}} elm-dev
@watch-html:
watchexec -p -w src -e html -- just config={{config}} html
@watch-typescript-dev:
watchexec -p -w src -e ts -- just config={{config}} typescript-dev