Commit 31d6310
committed
fix: set publicPath for Experience CS
**Background**
We use a fork of `scratch-gui` in the Experience CS app for rendering scratch
projects. This fork is essential as it allows us to specify where asset URLs are
served from (otherwise they are broken). We also use this fork to tweak the UI
and expose additional functionality. Up until now this fork has been based off
of a Google fork (which provides better keyboard accessiblity), but after a
number of user facing bugs we have decided to base our fork off of the official
`scratch-gui` repo. These Google changes are in the process of being merged
upstreamed and so we think this is the right approach. The official
`scratch-gui` project has moved on since the Google fork and relies on a newer
version of `scratch-storage`.
**The problem**
`scratch-gui` uses `scratch-storage` for loading scratch project files via a Web
Worker script so it can do so using a background thread [1]. This script is
loaded dynamically and relies on the webpack `output.publicPath` option [2] to
determine where to load this script from. Unfortunately we need this script to
load succesfully for scratch-gui to work and as with `scratch-gui` itself,
therefore we also need to configure `output.publicPath` for `scratch-storage`.
For our purposes we want assets to be served from `/scratch-gui`, and I can't
see the need to make this configurable at this stage, therefore I have hardcoded
this value for now as that also makes building the package less prone to error.
[1]
https://github.com/RaspberryPiFoundation/scratch-storage/blob/develop/src/FetchWorkerTool.ts
http://localhost:3000/scratch-gui/chunks/fetch-worker.7a0adc94df277ffeb963.js
[2]
https://webpack.js.org/guides/public-path/1 parent 21a1212 commit 31d6310
1 file changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| 75 | + | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
| |||
0 commit comments