Maybe almost the most minimal clicker game ever - produce as many units as you can!
-
What: The purpose of this project is to experiment with a Web Worker in a vue-cli project (with TypeScript).
-
How: See
Engine.ts, which acts as a proxy to the Web Workerworker.js. The application can call methods ofEngine.tsto post commands to the worker. The worker posts state updates toEngine.ts, which updates application State. -
Why: The Web Worker operates in an independent thread from the application's JavaScript thread. The worker can perform computations without degrading the app's responsiveness.
Granted, this is a bit over-engineered for this example...
yarn install: set up projectyarn serve: serve on localhost with hot-reloadingyarn build: build production distribution
Aside from standard vue-cli project, added the following for Web Worker support:
yarn add --dev worker-loader
I tried several configurations in vue.config.js to allow *.worker.js files to be loaded by worker-loader during the webpack process. None of this worked. The answer was to simply load workers explicitly:
import Worker from "worker-loader!./worker.js"
git checkout develop- Update
package.jsonwith versionX.Y.Z - For GitHub Pages hosting:
- Run
yarn buildto producedist - Remove old
docs& movedisttodocs - Remove all
*.mapsourcemaps withindocs(unneeded in repo) - Run
http-serverindocsto see if distribution works
- Run
git commit -am "vX.Y.Z"git checkout master && git merge develop && git tag X.Y.Z# novgit push --all && git push --tagsgit checkout develop# back to work
GitHub Pages is hosting
/docsoffmasterbranch.
MIT License © Nathaniel Baughman
Share and enjoy :)