Skip to content

Commit 0e85a9e

Browse files
Fix parcel commands; prevent possible issues by using 'example.html'file
- Seems like using 'index.html' as both the source and output can screw things up sometimes. Normally, parcel would output things to 'dist/index.html' So, this is my workaround for it.
1 parent 83cf554 commit 0e85a9e

File tree

8 files changed

+34
-7
lines changed

8 files changed

+34
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
# Ignore Parcel's files and directories
2323
/**/dist/**/*.js.map
24+
/**/dist/**/index.html
2425
/**/.cache/
2526

2627
# Ignore any project-related files stored in temporary folder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en" dir="ltr">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Game - Guess a Random Number ("Standard" ReaderT-Based)</title>
6+
</head>
7+
<body>
8+
<script src="/app.js" charset="utf-8"></script>
9+
</body>
10+
</html>

22-Projects/dist/random-number/readerT--standard/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
<title>Game - Guess a Random Number ("Standard" ReaderT-Based)</title>
66
</head>
77
<body>
8-
<script src="app.js" charset="utf-8"></script>
8+
<script src="/app.c328ef1a.js" charset="utf-8"></script>
99
</body>
1010
</html>

22-Projects/src/02-Random-Number/ReadMe.md

+22-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ This folder will show how to build a "guess the random number" game. Here's an o
99

1010
Run the following while in the `Projects/` folder.
1111

12-
The web-based games require a 2-step process of first running the `spago` command followed by the `parcel` command. The games can be opened and played via `dist/random-number/<FP structure approach>/index.html`.
12+
The web-based games require a 2-step process of first running the `spago` command followed by the `parcel` command. The below `parcel` commands are rather verbose because of how this folder is structured. See the overview of the first instance of the command in the below compilation instructions.
13+
14+
The games can be opened and played via `dist/random-number/<FP structure approach>/index.html`.
1315

1416
### Standard
1517

@@ -21,13 +23,27 @@ spago run -m Games.RandomNumber.Run.Standard.Infrastructure.Console
2123

2224
## Browser-based implementation
2325
spago bundle --main Games.RandomNumber.ReaderT.Standard.Infrastructure.Halogen.Web --to dist/random-number/readerT--standard/app.js
24-
parcel build -o dist/random-number/readerT--standard/app.js dist/random-number/readerT--standard/index.html
26+
# Read the below as:
27+
# "Use 'example.html' to figure out the dependency tree, which will pick up
28+
# our 'app.js' bundle from Spago. Parcel will output a minified version
29+
# of the `app.js` bundle to the path:
30+
# 'dist/random-number/readert--standard/app.someHash.js'.
31+
# Then, the `example.html` file will be copied to `index.html` and the `app.js`
32+
# reference will be changed to the parcel-ed `app.someHash.js` reference.
33+
#
34+
# Since we have the '--open' flag enabled and specify the port to `1111,`
35+
# your web browser will open 'localhost:1111', which automatically serves the
36+
# 'index.html' file that parcel outputted.
37+
#
38+
# From here, you can modify your code, re-bundle with spago, and Parcel
39+
# will hotload the changes."
40+
parcel dist/random-number/readerT--standard/example.html --open -p 1111 -d dist/random-number/readerT--standard/ -o index.html
2541

2642
spago bundle --main Games.RandomNumber.Free.Standard.Infrastructure.Halogen.Web --to dist/random-number/free--standard/app.js
27-
parcel build -o dist/random-number/free--standard/index.html
43+
parcel build dist/random-number/free--standard/example.html --open -p 1112 -d dist/random-number/free--standard/ -o index.html
2844

2945
spago bundle --main Games.RandomNumber.Run.Standard.Infrastructure.Halogen.Web --to dist/random-number/run--standard/app.js
30-
parcel build -o dist/random-number/run--standard/app.js dist/random-number/run--standard/index.html
46+
parcel build dist/random-number/run--standard/example.html --open -p 1113 -d dist/random-number/run--standard/ -o index.html
3147

3248
## Test
3349
spago test -m Test.Games.RandomNumber.ReaderT.Standard.DifferentMonad
@@ -49,10 +65,10 @@ spago run -m Games.RandomNumber.Run.Layered.AddDomainTerm
4965

5066
## Browser-based implementation
5167
spago build --main Games.RandomNumber.Free.Layered.Infrastructure.Halogen.Web --to dist/random-number/free--layered/app.js
52-
parcel build -o dist/random-number/free--layered/app.js dist/random-number/free--layered/index.html
68+
parcel build dist/random-number/free--layered/example.html --open -p 1114 -d dist/random-number/free--layered/ -o index.html
5369

5470
spago build --main Games.RandomNumber.Run.Layered.Infrastructure.Halogen.Web --to dist/random-number/run--layered/app.js
55-
parcel build -o dist/random-number/run--layered/app.js dist/random-number/run--layered/index.html
71+
parcel build dist/random-number/run--layered/example.html --open -p 1115 -d dist/random-number/run--layered/ -o index.html
5672

5773
## Test
5874
spago test -m Test.Games.RandomNumber.Run.Layered.Infrastructure

0 commit comments

Comments
 (0)